void STATE_APIENTRY crStateDeleteBuffersARB(GLsizei n, const GLuint *buffers) { CRContext *g = GetCurrentContext(); int i; FLUSH(); if (g->current.inBeginEnd) { crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "glDeleteBuffersARB called in Begin/End"); return; } if (n < 0) { crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, "glDeleteBuffersARB(n < 0)"); return; } for (i = 0; i < n; i++) { if (buffers[i]) { CRBufferObject *obj = (CRBufferObject *) crHashtableSearch(g->shared->buffersTable, buffers[i]); if (obj) { int j; ctStateBuffersRefsCleanup(g, obj, g->neg_bitid); CR_STATE_SHAREDOBJ_USAGE_FOREACH_USED_IDX(obj, j) { /* saved state version <= SHCROGL_SSM_VERSION_BEFORE_CTXUSAGE_BITS does not have usage bits info, * so on restore, we set mark bits as used. * This is why g_pAvailableContexts[j] could be NULL * also g_pAvailableContexts[0] will hold default context, which we should discard */ CRContext *ctx = g_pAvailableContexts[j]; if (j && ctx) { ctStateBuffersRefsCleanup(ctx, obj, g->neg_bitid); /* <- yes, use g->neg_bitid, i.e. neg_bitid of the current context to ensure others bits get dirtified, * but not the current context ones*/ } else CR_STATE_SHAREDOBJ_USAGE_CLEAR_IDX(obj, j); } crHashtableDelete(g->shared->buffersTable, buffers[i], crStateFreeBufferObject); } } }
DECLEXPORT(void) STATE_APIENTRY crStateDeleteRenderbuffersEXT(GLsizei n, const GLuint *renderbuffers) { CRContext *g = GetCurrentContext(); CRFramebufferObjectState *fbo = &g->framebufferobject; int i; CRSTATE_CHECKERR(g->current.inBeginEnd, GL_INVALID_OPERATION, "called in begin/end"); CRSTATE_CHECKERR(n<0, GL_INVALID_OPERATION, "n<0"); for (i = 0; i < n; i++) { if (renderbuffers[i]) { CRRenderbufferObject *rbo; rbo = (CRRenderbufferObject*) crHashtableSearch(g->shared->rbTable, renderbuffers[i]); if (rbo) { int j; ctStateRenderbufferRefsCleanup(g, renderbuffers[i], rbo); CR_STATE_SHAREDOBJ_USAGE_FOREACH_USED_IDX(rbo, j) { /* saved state version <= SHCROGL_SSM_VERSION_BEFORE_CTXUSAGE_BITS does not have usage bits info, * so on restore, we set mark bits as used. * This is why g_pAvailableContexts[j] could be NULL * also g_pAvailableContexts[0] will hold default context, which we should discard */ CRContext *ctx = g_pAvailableContexts[j]; if (j && ctx) { CRFramebufferObjectState *ctxFbo; CRASSERT(ctx); ctxFbo = &ctx->framebufferobject; if (ctxFbo->renderbuffer==rbo) crWarning("deleting RBO being used by another context %d", ctx->id); ctStateRenderbufferRefsCleanup(ctx, renderbuffers[i], rbo); } else CR_STATE_SHAREDOBJ_USAGE_CLEAR_IDX(rbo, j); } crHashtableDelete(g->shared->rbTable, renderbuffers[i], crStateFreeRBO); } } }