state_snapshot.c revision bda4b6d062e1dffc2d3fa9d4a851666903fdfd1d
/* $Id$ */
/** @file
*/
/*
* Copyright (C) 2008-2013 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*/
#include "state.h"
#include "state_internals.h"
#include "state/cr_statetypes.h"
#include "state/cr_texture.h"
#include "cr_mem.h"
#include "cr_string.h"
#include "cr_pixeldata.h"
#include <stdio.h>
/* @todo
*
* The drawback is we have to deal with all the pointers around those structures,
* we'd have to update this code if we'd change state tracking.
* On the bright side it's fast, though it's not really needed as it's not that often operation.
* It could also worth to split those functions into appropriate parts,
* similar to the way context creation is being done.
*
* Second way would be to implement full dispatch api table and substitute diff_api during saving/loading.
* via provided pSSM handle instead of pack buffer,
* saving state could be done by simple diffing against empty "dummy" context.
* Restoring state in such case would look like unpacking commands from pSSM instead of network buffer.
* This would be slower (who cares) but most likely will not require any code changes to support in future.
* We will reduce amount of saved data as we'd save only changed state parts, but I doubt it'd be that much.
* It could be done for the first way as well, but requires tons of bit checks.
*/
{
if (!*pBuffer)
return VERR_NO_MEMORY;
}
} while (0)
} while (0)
} while (0)
#define SHCROGL_CUT_FIELD_ALIGNMENT_SIZE(_type, _prevField, _field) (RT_OFFSETOF(_type, _field) - RT_OFFSETOF(_type, _prevField) - RT_SIZEOFMEMB(_type, _prevField))
/*AssertCompile(SHCROGL_CUT_FIELD_ALIGNMENT_SIZE(_type, _prevField, _field) >= 0 && SHCROGL_CUT_FIELD_ALIGNMENT_SIZE(_type, _prevField, _field) < sizeof (void*));*/ \
if (cbAlignment) { \
} \
} while (0)
#define SHCROGL_CUT_FOR_OLD_TYPE_TO_ENSURE_ALIGNMENT_SIZE(_type, _field, _oldFieldType, _nextFieldAllignment) (SHCROGL_ALIGNTAILSIZE(((RT_OFFSETOF(_type, _field) + sizeof (_oldFieldType))), (_nextFieldAllignment)))
#define SHCROGL_CUT_FOR_OLD_TYPE_TO_ENSURE_ALIGNMENT(_type, _field, _oldFieldType, _nextFieldAllignment) do { \
const int32_t cbAlignment = SHCROGL_CUT_FOR_OLD_TYPE_TO_ENSURE_ALIGNMENT_SIZE(_type, _field, _oldFieldType, _nextFieldAllignment); \
/*AssertCompile(SHCROGL_CUT_TAIL_ALIGNMENT_SIZE(_type, _lastField) >= 0 && SHCROGL_CUT_TAIL_ALIGNMENT_SIZE(_type, _lastField) < sizeof (void*));*/ \
if (cbAlignment) { \
} \
} while (0)
#define SHCROGL_CUT_TAIL_ALIGNMENT_SIZE(_type, _lastField) (sizeof (_type) - RT_OFFSETOF(_type, _lastField) - RT_SIZEOFMEMB(_type, _lastField))
/*AssertCompile(SHCROGL_CUT_TAIL_ALIGNMENT_SIZE(_type, _lastField) >= 0 && SHCROGL_CUT_TAIL_ALIGNMENT_SIZE(_type, _lastField) < sizeof (void*));*/ \
if (cbAlignment) { \
} \
} while (0)
static int32_t crStateLoadTextureObj_v_BEFORE_CTXUSAGE_BITS(CRTextureObj *pTexture, PSSMHANDLE pSSM)
{
/* just make all bits are used so that we fall back to the pre-ctxUsage behavior,
* i.e. all shared resources will be destructed on last shared context termination */
return rc;
}
{
#ifdef CR_ARB_texture_cube_map
# define SHCROGL_INTERNAL_LAST_FIELD SavedCubeMap
#else
# define SHCROGL_INTERNAL_LAST_FIELD Saved3D
#endif
#ifdef CR_NV_texture_rectangle
# define SHCROGL_INTERNAL_LAST_FIELD SavedRect
#endif
return rc;
}
{
int rc = VINF_SUCCESS;
return rc;
}
{
s->stencilTwoSideEXT = GL_FALSE;
s->activeStencilFace = GL_FRONT;
return VINF_SUCCESS;
}
{
GLint i;
#ifdef CR_ARB_texture_cube_map
# define SHCROGL_INTERNAL_LAST_FIELD baseCubeMap
#else
# define SHCROGL_INTERNAL_LAST_FIELD base3D
#endif
#ifdef CR_NV_texture_rectangle
# define SHCROGL_INTERNAL_LAST_FIELD baseRect
#endif
#ifdef CR_ARB_texture_cube_map
# define SHCROGL_INTERNAL_LAST_FIELD proxyCubeMap
#else
# define SHCROGL_INTERNAL_LAST_FIELD proxy3D
#endif
#ifdef CR_NV_texture_rectangle
# define SHCROGL_INTERNAL_LAST_FIELD proxyRect
#endif
for (i = 0; i < CR_MAX_TEXTURE_UNITS; ++i)
{
}
return VINF_SUCCESS;
}
{
s->stencilTwoSideEXT = GL_FALSE;
s->activeStencilFace = GL_FRONT;
return VINF_SUCCESS;
}
{
for (i = 0; i < CR_MAX_ATTRIB_STACK_DEPTH; ++i)
{
}
return rc;
}
{
for (i = 0; i < CR_MAX_TEXTURE_UNITS; ++i)
{
}
return rc;
}
{
for (i = 0; i < CR_MAX_ATTRIB_STACK_DEPTH; ++i)
{
}
for (i = 0; i < CR_MAX_ATTRIB_STACK_DEPTH; ++i)
{
}
return rc;
}
{
return rc;
}
static int32_t crStateLoadBufferObject(CRBufferObject *pBufferObj, PSSMHANDLE pSSM, uint32_t u32Version)
{
{
/* just make all bits are used so that we fall back to the pre-ctxUsage behavior,
* i.e. all shared resources will be destructed on last shared context termination */
}
else
{
}
return rc;
}
static int32_t crStateLoadFramebufferObject(CRFramebufferObject *pFBO, PSSMHANDLE pSSM, uint32_t u32Version)
{
{
/* just make all bits are used so that we fall back to the pre-ctxUsage behavior,
* i.e. all shared resources will be destructed on last shared context termination */
}
else
{
}
return rc;
}
static int32_t crStateLoadRenderbufferObject(CRRenderbufferObject *pRBO, PSSMHANDLE pSSM, uint32_t u32Version)
{
{
/* just make all bits are used so that we fall back to the pre-ctxUsage behavior,
* i.e. all shared resources will be destructed on last shared context termination */
}
else
{
}
return rc;
}
{
for (i = 0; i < CR_MAX_MIPMAP_LEVELS; i++) {
{
}
/* Note, this is not a bug.
* Even with CR_STATE_NO_TEXTURE_IMAGE_STORE defined, it's possible that ptl->img!=NULL.
* For ex. we're saving snapshot right after it was loaded
* and some context hasn't been used by the guest application yet
* (pContext->shared->bTexResyncNeeded==GL_TRUE).
*/
{
char *pImg;
if (!bound)
{
bound = 1;
/* osx nvidia drivers seem to have a bug that 1x1 TEXTURE_2D texture becmes inaccessible for some reason
* saw that for 1x1 dummy textures generated by wine
* to avoid crashes we skip texture data save if that is the case */
{
case GL_TEXTURE_1D:
break;
case GL_TEXTURE_2D:
break;
case GL_TEXTURE_3D:
break;
case GL_TEXTURE_RECTANGLE_ARB:
break;
case GL_TEXTURE_CUBE_MAP_ARB:
break;
default:
getEnum = 0;
break;
}
if (getEnum)
{
{
crWarning("texture not bound properly: expected %d, but was %d. Texture state data: target(0x%x), id(%d), w(%d), h(%d)",
bound = -1;
}
}
}
{
}
else
{
}
#ifdef DEBUG
#else
#endif
if (!pImg) return VERR_NO_MEMORY;
#ifdef DEBUG
#endif
if (bound > 0)
{
#ifdef DEBUG
{
GLint w,h=0;
crDebug("get image: compressed %i, face %i, level %i, width %i, height %i, bytes %i",
{
crWarning("!!!tex size mismatch %i, %i!!!", w, h);
}
}
#endif
/*@todo: ugly workaround for crashes inside ati driver,
* they overwrite their own allocated memory in cases where texlevel >=4
and width or height <=2.
*/
{
if (!ptl->compressed)
{
}
else
{
}
}
}
else
{
}
#ifdef DEBUG
{
crWarning("Texture is bigger than expected!!!");
}
#endif
}
#endif
}
}
return VINF_SUCCESS;
}
{
for (i = 0; i < CR_MAX_MIPMAP_LEVELS; i++) {
{
}
/* Same story as in crStateSaveTextureObjData */
{
}
#endif
}
}
return VINF_SUCCESS;
}
{
}
{
}
{
/* fixup stack top pointer */
return rc;
}
{
/* Current texture pointer can't be NULL for real texture unit states,
* but it could be NULL for unused attribute stack depths.
*/
if (pTexture)
else
return VINF_SUCCESS;
}
static int32_t crStateLoadTextureObjPtr(CRTextureObj **pTexture, CRContext *pContext, GLenum target, PSSMHANDLE pSSM)
{
/* We're loading attrib stack with unused state */
if (!*pTexture)
return VINF_SUCCESS;
if (texName)
{
}
else
{
switch (target)
{
case GL_TEXTURE_1D:
break;
case GL_TEXTURE_2D:
break;
#ifdef CR_OPENGL_VERSION_1_2
case GL_TEXTURE_3D:
break;
#endif
#ifdef CR_ARB_texture_cube_map
case GL_TEXTURE_CUBE_MAP_ARB:
break;
#endif
#ifdef CR_NV_texture_rectangle
case GL_TEXTURE_RECTANGLE_NV:
break;
#endif
default:
}
}
return rc;
}
{
#ifdef CR_ARB_texture_cube_map
#endif
#ifdef CR_NV_texture_rectangle
#endif
return rc;
}
static int32_t crStateLoadTexUnitCurrentTexturePtrs(CRTextureUnit *pTexUnit, CRContext *pContext, PSSMHANDLE pSSM)
{
#ifdef CR_ARB_texture_cube_map
rc = crStateLoadTextureObjPtr(&pTexUnit->currentTextureCubeMap, pContext, GL_TEXTURE_CUBE_MAP_ARB, pSSM);
#endif
#ifdef CR_NV_texture_rectangle
rc = crStateLoadTextureObjPtr(&pTexUnit->currentTextureRect, pContext, GL_TEXTURE_RECTANGLE_NV, pSSM);
#endif
return rc;
}
{
for (i=0; i<GLEVAL_TOT; ++i)
{
{
}
}
return VINF_SUCCESS;
}
{
for (i=0; i<GLEVAL_TOT; ++i)
{
{
rc = SSMR3PutMem(pSSM, pEval[i].coeff, pEval[i].uorder * pEval[i].vorder * gleval_sizes[i] * sizeof(GLfloat));
}
}
return VINF_SUCCESS;
}
{
for (i=0; i<GLEVAL_TOT; ++i)
{
{
if (bReallocMem)
{
}
}
}
return VINF_SUCCESS;
}
{
for (i=0; i<GLEVAL_TOT; ++i)
{
{
if (bReallocMem)
{
}
}
}
return VINF_SUCCESS;
}
{
int32_t i;
for (i=0; i<GLEVAL_TOT; ++i)
/*
pDst[GL_MAP1_VERTEX_3-GL_MAP1_COLOR_4].coeff = pSrc[GL_MAP1_VERTEX_3-GL_MAP1_COLOR_4].coeff;
pDst[GL_MAP1_VERTEX_4-GL_MAP1_COLOR_4].coeff = pSrc[GL_MAP1_VERTEX_4-GL_MAP1_COLOR_4].coeff;
pDst[GL_MAP1_INDEX-GL_MAP1_COLOR_4].coeff = pSrc[GL_MAP1_INDEX-GL_MAP1_COLOR_4].coeff;
pDst[GL_MAP1_COLOR_4-GL_MAP1_COLOR_4].coeff = pSrc[GL_MAP1_COLOR_4-GL_MAP1_COLOR_4].coeff;
pDst[GL_MAP1_NORMAL-GL_MAP1_COLOR_4].coeff = pSrc[GL_MAP1_NORMAL-GL_MAP1_COLOR_4].coeff;
pDst[GL_MAP1_TEXTURE_COORD_1-GL_MAP1_COLOR_4].coeff = pSrc[GL_MAP1_TEXTURE_COORD_1-GL_MAP1_COLOR_4].coeff;
pDst[GL_MAP1_TEXTURE_COORD_2-GL_MAP1_COLOR_4].coeff = pSrc[GL_MAP1_TEXTURE_COORD_2-GL_MAP1_COLOR_4].coeff;
pDst[GL_MAP1_TEXTURE_COORD_3-GL_MAP1_COLOR_4].coeff = pSrc[GL_MAP1_TEXTURE_COORD_3-GL_MAP1_COLOR_4].coeff;
pDst[GL_MAP1_TEXTURE_COORD_4-GL_MAP1_COLOR_4].coeff = pSrc[GL_MAP1_TEXTURE_COORD_4-GL_MAP1_COLOR_4].coeff;
*/
}
{
int32_t i;
for (i=0; i<GLEVAL_TOT; ++i)
/*
pDst[GL_MAP2_VERTEX_3-GL_MAP2_COLOR_4].coeff = pSrc[GL_MAP2_VERTEX_3-GL_MAP2_COLOR_4].coeff;
pDst[GL_MAP2_VERTEX_4-GL_MAP2_COLOR_4].coeff = pSrc[GL_MAP2_VERTEX_4-GL_MAP2_COLOR_4].coeff;
pDst[GL_MAP2_INDEX-GL_MAP2_COLOR_4].coeff = pSrc[GL_MAP2_INDEX-GL_MAP2_COLOR_4].coeff;
pDst[GL_MAP2_COLOR_4-GL_MAP2_COLOR_4].coeff = pSrc[GL_MAP2_COLOR_4-GL_MAP2_COLOR_4].coeff;
pDst[GL_MAP2_NORMAL-GL_MAP2_COLOR_4].coeff = pSrc[GL_MAP2_NORMAL-GL_MAP2_COLOR_4].coeff;
pDst[GL_MAP2_TEXTURE_COORD_1-GL_MAP2_COLOR_4].coeff = pSrc[GL_MAP2_TEXTURE_COORD_1-GL_MAP2_COLOR_4].coeff;
pDst[GL_MAP2_TEXTURE_COORD_2-GL_MAP2_COLOR_4].coeff = pSrc[GL_MAP2_TEXTURE_COORD_2-GL_MAP2_COLOR_4].coeff;
pDst[GL_MAP2_TEXTURE_COORD_3-GL_MAP2_COLOR_4].coeff = pSrc[GL_MAP2_TEXTURE_COORD_3-GL_MAP2_COLOR_4].coeff;
pDst[GL_MAP2_TEXTURE_COORD_4-GL_MAP2_COLOR_4].coeff = pSrc[GL_MAP2_TEXTURE_COORD_4-GL_MAP2_COLOR_4].coeff;
*/
}
{
if (pBufferObj->data)
{
/*We could get here even though retainBufferData is false on host side, in case when we're taking snapshot
after state load and before this context was ever made current*/
}
{
if (pBufferObj->pointer)
{
}
}
}
{
{
}
{
{
}
}
}
{
}
{
}
{
unsigned long key;
/* we're loading default vertex or pixel program*/
if (*ppProgram)
{
if (key!=0) return VERR_SSM_UNEXPECTED_DATA;
}
else
{
if (!ppProgram) return VERR_NO_MEMORY;
if (key==0) return VERR_SSM_UNEXPECTED_DATA;
}
{
}
{
if (!ppSymbol) return VERR_NO_MEMORY;
{
}
}
return VINF_SUCCESS;
}
{
if (pStr)
{
}
else
{
}
}
{
if (len!=0)
{
}
return pStr;
}
{
{
}
else
{
if (sLen>0)
{
}
}
}
{
unsigned long key;
return pShader;
}
{
}
{
GLuint i;
{
}
}
{
{
}
if (!maxUniformLen)
{
if (activeUniforms)
{
activeUniforms = 0;
}
}
if (activeUniforms>0)
{
if (!name)
{
crWarning("crStateSaveGLSLProgramCB: out of memory");
return;
}
}
for (i=0; i<activeUniforms; ++i)
{
uniformsCount += size;
}
if (activeUniforms>0)
{
for (i=0; i<activeUniforms; ++i)
{
if (size>1)
{
if (!pIndexStr)
{
}
}
for (j=0; j<size; ++j)
{
if (size>1)
{
}
if (crStateIsIntUniform(type))
{
}
else
{
}
}
}
}
}
{
else
#ifdef CR_EXT_compiled_vertex_array
{
}
#endif
return VINF_SUCCESS;
}
static int32_t crStateLoadClientPointer(CRVertexArrays *pArrays, int32_t index, CRContext *pContext, PSSMHANDLE pSSM)
{
cp->buffer = ui==0 ? pContext->bufferobject.nullBuffer : crHashtableSearch(pContext->shared->buffersTable, ui);
{
}
#ifdef CR_EXT_compiled_vertex_array
{
rc = crStateAllocAndSSMR3GetMem(pSSM, (void**)&cp->p, cp->stride*(pArrays->lockFirst+pArrays->lockCount));
}
#endif
return VINF_SUCCESS;
}
{
for (i=0; i<CR_MAX_TEXTURE_UNITS; i++)
{
}
#ifdef CR_NV_vertex_program
for (i=0; i<CR_MAX_VERTEX_ATTRIBS; i++)
{
}
#endif
return VINF_SUCCESS;
}
{
for (i=0; i<CR_MAX_TEXTURE_UNITS; i++)
{
}
#ifdef CR_NV_vertex_program
for (i=0; i<CR_MAX_VERTEX_ATTRIBS; i++)
{
}
#endif
for (i=0; i<CR_MAX_TEXTURE_UNITS; i++)
{
}
#ifdef CR_NV_vertex_program
for (i=0; i<CR_MAX_VERTEX_ATTRIBS; i++)
{
}
#endif
return VINF_SUCCESS;
}
{
int rc;
}
{
/* use null terminator */
SSMR3PutU32(pSSM, 0);
return VINF_SUCCESS;
}
{
int rc;
for(;;)
{
if (!u32Key)
return rc;
{
{
#if 0 //def DEBUG_misha
#endif
}
}
}
return rc;
}
{
/* this stuff is not used anymore, zero it up for sanity */
/* make sure the gl error state is captured by our state mechanism to store the correct gl error value */
crWarning("Saving state with %d display lists, unsupported", crHashtableNumElements(pContext->shared->dlistTable));
{
{
}
}
/* Save transform state */
for (i = 0 ; i < CR_MAX_TEXTURE_UNITS ; i++)
{
}
for (i = 0 ; i < CR_MAX_PROGRAM_MATRICES ; i++)
{
}
/* Save textures */
#ifdef CR_ARB_texture_cube_map
#endif
#ifdef CR_NV_texture_rectangle
#endif
/* Save shared textures */
if (bSaveShared)
{
/* Restore previous texture bindings via diff_api */
if (ui32)
{
#ifdef CR_ARB_texture_cube_map
#endif
#ifdef CR_NV_texture_rectangle
#endif
}
#endif
}
/* Save current texture pointers */
for (i=0; i<CR_MAX_TEXTURE_UNITS; ++i)
{
}
/* Save lights */
rc = SSMR3PutMem(pSSM, pContext->lighting.light, CR_MAX_LIGHTS * sizeof(*pContext->lighting.light));
/* Save attrib stack*/
/*@todo could go up to used stack depth here?*/
for ( i = 0 ; i < CR_MAX_ATTRIB_STACK_DEPTH ; i++)
{
{
}
{
}
{
}
{
}
{
}
{
}
}
/* Save evaluator coeffs */
#ifdef CR_ARB_vertex_buffer_object
/* Save buffer objects */
if (bSaveShared)
{
}
/* Save default one*/
if (bSaveShared)
{
/* Save all the rest */
}
/* Restore binding */
/* Save pointers */
#ifdef CR_ARB_pixel_buffer_object
#endif
/* Save clint pointers and buffer bindings*/
for (i=0; i<CRSTATECLIENT_MAX_VERTEXARRAYS; ++i)
{
}
{
for (j=0; j<CRSTATECLIENT_MAX_VERTEXARRAYS; ++j)
{
}
}
#endif /*CR_ARB_vertex_buffer_object*/
/* Save defaults programs */
/* Save all the rest */
/* Save Pointers */
/* This one is unused it seems*/
#ifdef CR_EXT_framebuffer_object
/* Save FBOs */
if (bSaveShared)
{
}
rc = SSMR3PutU32(pSSM, pContext->framebufferobject.drawFB?pContext->framebufferobject.drawFB->id:0);
rc = SSMR3PutU32(pSSM, pContext->framebufferobject.readFB?pContext->framebufferobject.readFB->id:0);
rc = SSMR3PutU32(pSSM, pContext->framebufferobject.renderbuffer?pContext->framebufferobject.renderbuffer->id:0);
#endif
#ifdef CR_OPENGL_VERSION_2_0
/* Save GLSL related info */
#endif
return VINF_SUCCESS;
}
typedef struct _crFindSharedCtxParms {
{
(void) key;
{
}
}
{
/* don't need that for now */
#if 0
int rc;
if (g_cContexts <= 1)
return VINF_SUCCESS;
pBits = GetCurrentBits();
#include "state_bits_globalop.h"
#endif
return VINF_SUCCESS;
}
{
int rc;
if (g_cContexts <= 1)
return VINF_SUCCESS;
pBits = GetCurrentBits();
{
{
#include "state_bits_globalop.h"
}
{
#include "state_bits_globalop.h"
}
else
{
/* we do not put dirty bits to state anymore,
* nop */
//#include "state_bits_globalop.h"
}
/* always dirty all bits */
/* return VINF_SUCCESS; */
}
#include "state_bits_globalop.h"
return VINF_SUCCESS;
}
AssertCompile(RT_OFFSETOF(CRContext, shared) >= VBOXTLSREFDATA_OFFSET(CRContext) + VBOXTLSREFDATA_SIZE() + RT_SIZEOFMEMB(CRContext, bitid) + RT_SIZEOFMEMB(CRContext, neg_bitid));
int32_t crStateLoadContext(CRContext *pContext, CRHashTable * pCtxTable, PFNCRSTATE_CONTEXT_GET pfnCtxGet, PSSMHANDLE pSSM, uint32_t u32Version)
{
unsigned long key;
/* This one is rather big for stack allocation and causes macs to crash */
if (!pTmpContext)
return VERR_NO_MEMORY;
{
union {
struct {
} tlsRef;
} bitid;
/* do not increment the saved state version due to VBOXTLSREFDATA addition to CRContext */
/* VBox 4.1.8 had a bug that VBOXTLSREFDATA was also stored in the snapshot,
* thus the saved state data format was changed w/o changing the saved state version.
* here we determine whether the saved state contains VBOXTLSREFDATA, and if so, treat it accordingly */
/* the bitid array has one bit set only. this is why if bitid.tlsRef has both cTlsRefs
* and enmTlsRefState non-zero - this is definitely NOT a bit id and is a VBOXTLSREFDATA */
{
/* VBOXTLSREFDATA is stored, skip it */
crMemcpy(&pTmpContext->bitid, ((uint8_t*)&bitid) + VBOXTLSREFDATA_SIZE(), sizeof (bitid) - VBOXTLSREFDATA_SIZE());
rc = SSMR3GetMem(pSSM, ((uint8_t*)&pTmpContext->bitid) + sizeof (pTmpContext->bitid) - VBOXTLSREFDATA_SIZE(), sizeof (pTmpContext->neg_bitid) + VBOXTLSREFDATA_SIZE());
ui = VBOXTLSREFDATA_OFFSET(CRContext) + VBOXTLSREFDATA_SIZE() + sizeof (pTmpContext->bitid) + sizeof (pTmpContext->neg_bitid);
}
else
{
/* VBOXTLSREFDATA is NOT stored */
/* the pre-VBOXTLSREFDATA CRContext structure might have additional allignment bits before the CRContext::shared */
ui = VBOXTLSREFDATA_OFFSET(CRContext) + sizeof (pTmpContext->bitid) + sizeof (pTmpContext->neg_bitid);
ui &= (sizeof (void*) - 1);
}
if (ui)
{
}
{
SHCROGL_CUT_FOR_OLD_TYPE_TO_ENSURE_ALIGNMENT(CRContext, stencil, CRStencilState_v_33, sizeof (void*));
}
else
{
SHCROGL_CUT_FOR_OLD_TYPE_TO_ENSURE_ALIGNMENT(CRContext, stencil, CRStencilState_v_33, sizeof (void*));
}
* treat as no error */
}
else if (u32Version < SHCROGL_SSM_VERSION_WITH_FIXED_STENCIL)
{
SHCROGL_CUT_FOR_OLD_TYPE_TO_ENSURE_ALIGNMENT(CRContext, stencil, CRStencilState_v_33, sizeof (void*));
}
{
}
else
{
}
/* preserve the error to restore it at the end of context creation,
* it should not normally change, but just in case it it changed */
/* we will later do crMemcpy from entire pTmpContext to pContext,
* for simplicity store the VBOXTLSREFDATA from the pContext to pTmpContext */
/* Deal with shared state */
{
if (pTmpContext->shared)
{
}
else
{
}
if (bLoadShared && shared)
{
}
}
/* We're supposed to be loading into an empty context, so those pointers should be NULL */
for ( i = 0 ; i < CR_MAX_ATTRIB_STACK_DEPTH ; i++)
{
for (j=0; j<GLEVAL_TOT; ++j)
{
}
}
#ifdef CR_ARB_vertex_buffer_object
#endif
/*@todo, that should be removed probably as those should hold the offset values, so loading should be fine
but better check*/
#if 0
#ifdef CR_EXT_compiled_vertex_array
for (i = 0 ; i < CR_MAX_TEXTURE_UNITS ; i++)
{
}
# ifdef CR_NV_vertex_program
for (i = 0; i < CR_MAX_VERTEX_ATTRIBS; i++)
{
}
# endif
#endif
#endif
#ifdef CR_ARB_vertex_buffer_object
/*That just sets those pointers to NULL*/
for (i = 0 ; i < CR_MAX_TEXTURE_UNITS ; i++)
{
}
# ifdef CR_NV_vertex_program
for (i = 0; i < CR_MAX_VERTEX_ATTRIBS; i++)
{
}
# endif
#endif /*CR_ARB_vertex_buffer_object*/
/*@todo CR_NV_vertex_program*/
/*This one could be tricky if we're loading snapshot on host with different GPU*/
#endif
/* Texture pointers */
for (i=0; i<6; ++i)
{
#ifdef CR_ARB_texture_cube_map
#endif
#ifdef CR_NV_texture_rectangle
#endif
}
/* Load transform state */
/* Don't have to worry about pContext->transform.current as it'd be set in crStateSetCurrent call */
/*SLC_COPYPTR(transform.currentStack);*/
for (i = 0 ; i < CR_MAX_TEXTURE_UNITS ; i++)
{
}
for (i = 0 ; i < CR_MAX_PROGRAM_MATRICES ; i++)
{
}
#ifdef CR_OPENGL_VERSION_2_0
#endif
/* Have to preserve original context id */
/* Copy ordinary state to real context */
pTmpContext = NULL;
/* Now deal with pointers */
/* Load transform state */
for (i = 0 ; i < CR_MAX_TEXTURE_UNITS ; i++)
{
}
for (i = 0 ; i < CR_MAX_PROGRAM_MATRICES ; i++)
{
}
/* Load Textures */
#ifdef CR_ARB_texture_cube_map
#endif
#ifdef CR_NV_texture_rectangle
#endif
if (bLoadShared)
{
/* Load shared textures */
{
}
{
if (!pTexture) return VERR_NO_MEMORY;
/*allocate actual memory*/
for (i=0; i<6; ++i) {
}
}
}
/* Load current texture pointers */
for (i=0; i<CR_MAX_TEXTURE_UNITS; ++i)
{
}
/* Mark textures for resending to GPU */
/* Load lights */
rc = SSMR3GetMem(pSSM, pContext->lighting.light, CR_MAX_LIGHTS * sizeof(*pContext->lighting.light));
/* Load attrib stack*/
for ( i = 0 ; i < CR_MAX_ATTRIB_STACK_DEPTH ; i++)
{
{
}
{
}
{
}
{
rc = crStateLoadTexUnitCurrentTexturePtrs(&pContext->attrib.textureStack[i].unit[k], pContext, pSSM);
}
{
}
{
}
}
/* Load evaluator coeffs */
/* Load buffer objects */
#ifdef CR_ARB_vertex_buffer_object
if (bLoadShared)
{
{
}
}
{
/* default one should be already allocated */
if (key==0)
{
if (!pBufferObj) return VERR_SSM_UNEXPECTED_DATA;
}
else
{
if (!pBufferObj) return VERR_NO_MEMORY;
}
pBufferObj->hwid = 0;
if (pBufferObj->data)
{
}
{
if (pBufferObj->data)
{
}
}
if (key!=0)
}
/* Load pointers */
#define CRS_GET_BO(name) (((name)==0) ? (pContext->bufferobject.nullBuffer) : crHashtableSearch(pContext->shared->buffersTable, name))
#ifdef CR_ARB_pixel_buffer_object
#endif
/* Load client pointers and array buffer bindings*/
for (i=0; i<CRSTATECLIENT_MAX_VERTEXARRAYS; ++i)
{
}
{
for (i=0; i<CRSTATECLIENT_MAX_VERTEXARRAYS; ++i)
{
}
}
#endif
/* Load defaults programs */
/* Load all the rest */
{
//DIRTY(pProgram->dirtyProgram, pContext->neg_bitid);
}
/* Load Pointers */
/* Mark programs for resending to GPU */
#ifdef CR_EXT_framebuffer_object
/* Load FBOs */
if (bLoadShared)
{
{
}
{
if (!pFBO) return VERR_NO_MEMORY;
}
{
}
{
if (!pRBO) return VERR_NO_MEMORY;
}
}
#endif
#ifdef CR_OPENGL_VERSION_2_0
/* Load GLSL related info */
{
if (!pShader) return VERR_SSM_UNEXPECTED_DATA;
}
{
if (!pProgram) return VERR_NO_MEMORY;
for (k=0; k<numShaders; ++k)
{
crHashtableAdd(pProgram->currentState.attachedShaders, key, crHashtableSearch(pContext->glsl.shaders, key));
}
{
for (k=0; k<numShaders; ++k)
{
if (!pShader) return VERR_SSM_UNEXPECTED_DATA;
}
}
pProgram->currentState.pAttribs = (CRGLSLAttrib*) crAlloc(pProgram->currentState.cAttribs*sizeof(CRGLSLAttrib));
{
rc = SSMR3GetMem(pSSM, &pProgram->currentState.pAttribs[k].index, sizeof(pProgram->currentState.pAttribs[k].index));
}
pProgram->activeState.pAttribs = (CRGLSLAttrib*) crAlloc(pProgram->activeState.cAttribs*sizeof(CRGLSLAttrib));
{
rc = SSMR3GetMem(pSSM, &pProgram->activeState.pAttribs[k].index, sizeof(pProgram->activeState.pAttribs[k].index));
}
{
}
{
{
{
}
}
}
/*Mark for resending to GPU*/
#endif
{
crWarning("context error state changed on context restore, was 0x%x, but became 0x%x, resetting to its original value",
}
return VINF_SUCCESS;
}