void crStateClientSwitch(CRClientBits *cb, CRbitvalue *bitID, CRContext *fromCtx, CRContext *toCtx) { const CRClientState *from = &(fromCtx->client); const CRClientState *to = &(toCtx->client); int i; if (CHECKDIRTY(cb->clientPointer, bitID)) { /* one or more vertex pointers is dirty */ if (CHECKDIRTY(cb->v, bitID)) { if (from->array.v.size != to->array.v.size || from->array.v.type != to->array.v.type || from->array.v.stride != to->array.v.stride || from->array.v.buffer != to->array.v.buffer) { diff_api.VertexPointer(to->array.v.size, to->array.v.type, to->array.v.stride, to->array.v.p); FILLDIRTY(cb->v); FILLDIRTY(cb->clientPointer); } CLEARDIRTY2(cb->v, bitID); } /* normal */ if (CHECKDIRTY(cb->n, bitID)) { if (from->array.n.type != to->array.n.type || from->array.n.stride != to->array.n.stride || from->array.n.buffer != to->array.n.buffer) { diff_api.NormalPointer(to->array.n.type, to->array.n.stride, to->array.n.p); FILLDIRTY(cb->n); FILLDIRTY(cb->clientPointer); } CLEARDIRTY2(cb->n, bitID); } /* color */ if (CHECKDIRTY(cb->c, bitID)) { if (from->array.c.size != to->array.c.size || from->array.c.type != to->array.c.type || from->array.c.stride != to->array.c.stride || from->array.c.buffer != to->array.c.buffer) { diff_api.ColorPointer(to->array.c.size, to->array.c.type, to->array.c.stride, to->array.c.p); FILLDIRTY(cb->c); FILLDIRTY(cb->clientPointer); } CLEARDIRTY2(cb->c, bitID); } /* index */ if (CHECKDIRTY(cb->i, bitID)) { if (from->array.i.type != to->array.i.type || from->array.i.stride != to->array.i.stride || from->array.i.buffer != to->array.i.buffer) { diff_api.IndexPointer(to->array.i.type, to->array.i.stride, to->array.i.p); FILLDIRTY(cb->i); FILLDIRTY(cb->clientPointer); } CLEARDIRTY2(cb->i, bitID); } /* texcoords */ for (i = 0; (unsigned int)i < toCtx->limits.maxTextureUnits; i++) { if (CHECKDIRTY(cb->t[i], bitID)) { if (from->array.t[i].size != to->array.t[i].size || from->array.t[i].type != to->array.t[i].type || from->array.t[i].stride != to->array.t[i].stride || from->array.t[i].buffer != to->array.t[i].buffer) { diff_api.ClientActiveTextureARB(GL_TEXTURE0_ARB + i); diff_api.TexCoordPointer(to->array.t[i].size, to->array.t[i].type, to->array.t[i].stride, to->array.t[i].p); FILLDIRTY(cb->t[i]); FILLDIRTY(cb->clientPointer); } CLEARDIRTY2(cb->t[i], bitID); } } /* edge flag */ if (CHECKDIRTY(cb->e, bitID)) { if (from->array.e.stride != to->array.e.stride || from->array.e.buffer != to->array.e.buffer) { diff_api.EdgeFlagPointer(to->array.e.stride, to->array.e.p); FILLDIRTY(cb->e); FILLDIRTY(cb->clientPointer); } CLEARDIRTY2(cb->e, bitID); } /* secondary color */ if (CHECKDIRTY(cb->s, bitID)) { if (from->array.s.size != to->array.s.size || from->array.s.type != to->array.s.type || from->array.s.stride != to->array.s.stride || from->array.s.buffer != to->array.s.buffer) { diff_api.SecondaryColorPointerEXT(to->array.s.size, to->array.s.type, to->array.s.stride, to->array.s.p); FILLDIRTY(cb->s); FILLDIRTY(cb->clientPointer); } CLEARDIRTY2(cb->s, bitID); } /* fog coord */ if (CHECKDIRTY(cb->f, bitID)) { if (from->array.f.type != to->array.f.type || from->array.f.stride != to->array.f.stride || from->array.f.buffer != to->array.f.buffer) { diff_api.FogCoordPointerEXT(to->array.f.type, to->array.f.stride, to->array.f.p); FILLDIRTY(cb->f); FILLDIRTY(cb->clientPointer); } CLEARDIRTY2(cb->f, bitID); } #if defined(CR_NV_vertex_program) || defined(CR_ARB_vertex_program) /* vertex attributes */ for (i = 0; (unsigned int)i < toCtx->limits.maxVertexProgramAttribs; i++) { if (CHECKDIRTY(cb->a[i], bitID)) { if (from->array.a[i].size != to->array.a[i].size || from->array.a[i].type != to->array.a[i].type || from->array.a[i].stride != to->array.a[i].stride || from->array.a[i].normalized != to->array.a[i].normalized || from->array.a[i].buffer != to->array.a[i].buffer) { diff_api.VertexAttribPointerARB(i, to->array.a[i].size, to->array.a[i].type, to->array.a[i].normalized, to->array.a[i].stride, to->array.a[i].p); FILLDIRTY(cb->a[i]); FILLDIRTY(cb->clientPointer); } CLEARDIRTY2(cb->a[i], bitID); } } #endif } if (CHECKDIRTY(cb->enableClientState, bitID)) { /* update vertex array enable/disable flags */ glAble able[2]; able[0] = diff_api.Disable; able[1] = diff_api.Enable; if (from->array.v.enabled != to->array.v.enabled) { able[to->array.v.enabled](GL_VERTEX_ARRAY); FILLDIRTY(cb->enableClientState); } if (from->array.n.enabled != to->array.n.enabled) { able[to->array.n.enabled](GL_NORMAL_ARRAY); FILLDIRTY(cb->enableClientState); } if (from->array.c.enabled != to->array.c.enabled) { able[to->array.c.enabled](GL_COLOR_ARRAY); FILLDIRTY(cb->enableClientState); } if (from->array.i.enabled != to->array.i.enabled) { able[to->array.i.enabled](GL_INDEX_ARRAY); FILLDIRTY(cb->enableClientState); } for (i = 0; (unsigned int)i < toCtx->limits.maxTextureUnits; i++) { if (from->array.t[i].enabled != to->array.t[i].enabled) { diff_api.ClientActiveTextureARB(GL_TEXTURE0_ARB + i); able[to->array.t[i].enabled](GL_TEXTURE_COORD_ARRAY); FILLDIRTY(cb->enableClientState); } } if (from->array.e.enabled != to->array.e.enabled) { able[to->array.e.enabled](GL_EDGE_FLAG_ARRAY); FILLDIRTY(cb->enableClientState); } if (from->array.s.enabled != to->array.s.enabled) { able[to->array.s.enabled](GL_SECONDARY_COLOR_ARRAY_EXT); FILLDIRTY(cb->enableClientState); } if (from->array.f.enabled != to->array.f.enabled) { able[to->array.f.enabled](GL_FOG_COORDINATE_ARRAY_EXT); FILLDIRTY(cb->enableClientState); } for (i = 0; (unsigned int)i < toCtx->limits.maxVertexProgramAttribs; i++) { if (from->array.a[i].enabled != to->array.a[i].enabled) { able[to->array.a[i].enabled](GL_VERTEX_ATTRIB_ARRAY0_NV + i); FILLDIRTY(cb->enableClientState); } } CLEARDIRTY2(cb->enableClientState, bitID); } }
static void crStateBufferObjectIntCmp(CRBufferObjectBits *bb, CRbitvalue *bitID, CRContext *fromCtx, CRContext *toCtx, GLboolean bSwitch) { CRBufferObjectState *from = &(fromCtx->bufferobject); const CRBufferObjectState *to = &(toCtx->bufferobject); /* ARRAY_BUFFER */ if (CHECKDIRTY(bb->arrayBinding, bitID)) { if (from->arrayBuffer != to->arrayBuffer) { GLuint bufferID = to->arrayBuffer ? to->arrayBuffer->hwid : 0; diff_api.BindBufferARB(GL_ARRAY_BUFFER_ARB, bufferID); if (bSwitch) { FILLDIRTY(bb->arrayBinding); FILLDIRTY(bb->dirty); } else { CLEARDIRTY2(bb->arrayBinding, bitID); from->arrayBuffer = to->arrayBuffer; } } if (bSwitch) CLEARDIRTY2(bb->arrayBinding, bitID); } if (to->arrayBuffer && CHECKDIRTY(to->arrayBuffer->dirty, bitID)) { /* update array buffer data */ CRBufferObject *bufObj = to->arrayBuffer; CRASSERT(bufObj); if (bufObj->dirtyStart == 0 && bufObj->dirtyLength == (int) bufObj->size) { /* update whole buffer */ diff_api.BufferDataARB(GL_ARRAY_BUFFER_ARB, bufObj->size, bufObj->data, bufObj->usage); } else { /* update sub buffer */ diff_api.BufferSubDataARB(GL_ARRAY_BUFFER_ARB, bufObj->dirtyStart, bufObj->dirtyLength, (char *) bufObj->data + bufObj->dirtyStart); } if (bSwitch) FILLDIRTY(bufObj->dirty); CLEARDIRTY2(bufObj->dirty, bitID); } /* ELEMENTS_BUFFER */ if (CHECKDIRTY(bb->elementsBinding, bitID)) { if (from->elementsBuffer != to->elementsBuffer) { GLuint bufferID = to->elementsBuffer ? to->elementsBuffer->hwid : 0; diff_api.BindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, bufferID); if (bSwitch) { FILLDIRTY(bb->elementsBinding); FILLDIRTY(bb->dirty); } else { CLEARDIRTY2(bb->elementsBinding, bitID); from->elementsBuffer = to->elementsBuffer; } } if (bSwitch) CLEARDIRTY2(bb->elementsBinding, bitID); } if (to->elementsBuffer && CHECKDIRTY(to->elementsBuffer->dirty, bitID)) { /* update array buffer data */ CRBufferObject *bufObj = to->elementsBuffer; CRASSERT(bufObj); if (bufObj->dirtyStart == 0 && bufObj->dirtyLength == (int) bufObj->size) { /* update whole buffer */ diff_api.BufferDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, bufObj->size, bufObj->data, bufObj->usage); } else { /* update sub buffer */ diff_api.BufferSubDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, bufObj->dirtyStart, bufObj->dirtyLength, (char *) bufObj->data + bufObj->dirtyStart); } if (bSwitch) FILLDIRTY(bufObj->dirty); CLEARDIRTY2(bufObj->dirty, bitID); } #ifdef CR_ARB_pixel_buffer_object /* PIXEL_PACK_BUFFER */ if (CHECKDIRTY(bb->packBinding, bitID)) { if (from->packBuffer != to->packBuffer) { GLuint bufferID = to->packBuffer ? to->packBuffer->hwid : 0; diff_api.BindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, bufferID); if (bSwitch) { FILLDIRTY(bb->packBinding); FILLDIRTY(bb->dirty); } else { CLEARDIRTY2(bb->packBinding, bitID); from->packBuffer = to->packBuffer; } } if (bSwitch) CLEARDIRTY2(bb->packBinding, bitID); } if (to->packBuffer && CHECKDIRTY(to->packBuffer->dirty, bitID)) { /* update array buffer data */ CRBufferObject *bufObj = to->packBuffer; CRASSERT(bufObj); if (bufObj->dirtyStart == 0 && bufObj->dirtyLength == (int) bufObj->size) { /* update whole buffer */ diff_api.BufferDataARB(GL_PIXEL_PACK_BUFFER_ARB, bufObj->size, bufObj->data, bufObj->usage); } else { /* update sub buffer */ diff_api.BufferSubDataARB(GL_PIXEL_PACK_BUFFER_ARB, bufObj->dirtyStart, bufObj->dirtyLength, (char *) bufObj->data + bufObj->dirtyStart); } if (bSwitch) FILLDIRTY(bufObj->dirty); CLEARDIRTY2(bufObj->dirty, bitID); } /* PIXEL_UNPACK_BUFFER */ if (CHECKDIRTY(bb->unpackBinding, bitID)) { if (from->unpackBuffer != to->unpackBuffer) { GLuint bufferID = to->unpackBuffer ? to->unpackBuffer->hwid : 0; diff_api.BindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, bufferID); if (bSwitch) { FILLDIRTY(bb->unpackBinding); FILLDIRTY(bb->dirty); } else { CLEARDIRTY2(bb->unpackBinding, bitID); from->unpackBuffer = to->unpackBuffer; } } if (bSwitch) CLEARDIRTY2(bb->unpackBinding, bitID); } if (to->unpackBuffer && CHECKDIRTY(to->unpackBuffer->dirty, bitID)) { /* update array buffer data */ CRBufferObject *bufObj = to->unpackBuffer; CRASSERT(bufObj); if (bufObj->dirtyStart == 0 && bufObj->dirtyLength == (int) bufObj->size) { /* update whole buffer */ diff_api.BufferDataARB(GL_PIXEL_UNPACK_BUFFER_ARB, bufObj->size, bufObj->data, bufObj->usage); } else { /* update sub buffer */ diff_api.BufferSubDataARB(GL_PIXEL_UNPACK_BUFFER_ARB, bufObj->dirtyStart, bufObj->dirtyLength, (char *) bufObj->data + bufObj->dirtyStart); } if (bSwitch) FILLDIRTY(bufObj->dirty); CLEARDIRTY2(bufObj->dirty, bitID); } #endif /*ifdef CR_ARB_pixel_buffer_object*/ }