GLboolean nouveau_context_create(gl_api api, const struct gl_config *visual, __DRIcontext *dri_ctx, unsigned major_version, unsigned minor_version, uint32_t flags, bool notify_reset, unsigned *error, void *share_ctx) { __DRIscreen *dri_screen = dri_ctx->driScreenPriv; struct nouveau_screen *screen = dri_screen->driverPrivate; struct nouveau_context *nctx; struct gl_context *ctx; if (flags & ~__DRI_CTX_FLAG_DEBUG) { *error = __DRI_CTX_ERROR_UNKNOWN_FLAG; return false; } if (notify_reset) { *error = __DRI_CTX_ERROR_UNKNOWN_ATTRIBUTE; return false; } ctx = screen->driver->context_create(screen, visual, share_ctx); if (!ctx) { *error = __DRI_CTX_ERROR_NO_MEMORY; return GL_FALSE; } driContextSetFlags(ctx, flags); nctx = to_nouveau_context(ctx); nctx->dri_context = dri_ctx; dri_ctx->driverPrivate = ctx; _mesa_compute_version(ctx); if (ctx->Version < major_version * 10 + minor_version) { nouveau_context_destroy(dri_ctx); *error = __DRI_CTX_ERROR_BAD_VERSION; return GL_FALSE; } /* Exec table initialization requires the version to be computed */ _mesa_initialize_dispatch_tables(ctx); _mesa_initialize_vbo_vtxfmt(ctx); if (nouveau_bo_new(context_dev(ctx), NOUVEAU_BO_VRAM, 0, 4096, NULL, &nctx->fence)) { nouveau_context_destroy(dri_ctx); *error = __DRI_CTX_ERROR_NO_MEMORY; return GL_FALSE; } *error = __DRI_CTX_ERROR_SUCCESS; return GL_TRUE; }
static void nvc0_destroy(struct pipe_context *pipe) { struct nvc0_context *nvc0 = nvc0_context(pipe); if (nvc0->screen->cur_ctx == nvc0) { nvc0->screen->cur_ctx = NULL; nvc0->screen->save_state = nvc0->state; nvc0->screen->save_state.tfb = NULL; } if (nvc0->base.pipe.stream_uploader) u_upload_destroy(nvc0->base.pipe.stream_uploader); /* Unset bufctx, we don't want to revalidate any resources after the flush. * Other contexts will always set their bufctx again on action calls. */ nouveau_pushbuf_bufctx(nvc0->base.pushbuf, NULL); nouveau_pushbuf_kick(nvc0->base.pushbuf, nvc0->base.pushbuf->channel); nvc0_context_unreference_resources(nvc0); nvc0_blitctx_destroy(nvc0); nouveau_context_destroy(&nvc0->base); }
static void nv50_destroy(struct pipe_context *pipe) { struct nv50_context *nv50 = nv50_context(pipe); if (nv50->screen->cur_ctx == nv50) { nv50->screen->cur_ctx = NULL; /* Save off the state in case another context gets created */ nv50->screen->save_state = nv50->state; } nouveau_pushbuf_bufctx(nv50->base.pushbuf, NULL); nouveau_pushbuf_kick(nv50->base.pushbuf, nv50->base.pushbuf->channel); nv50_context_unreference_resources(nv50); FREE(nv50->blit); nouveau_context_destroy(&nv50->base); }
static void nvc0_destroy(struct pipe_context *pipe) { struct nvc0_context *nvc0 = nvc0_context(pipe); if (nvc0->screen->cur_ctx == nvc0) { nvc0->base.pushbuf->kick_notify = NULL; nvc0->screen->cur_ctx = NULL; nouveau_pushbuf_bufctx(nvc0->base.pushbuf, NULL); } nouveau_pushbuf_kick(nvc0->base.pushbuf, nvc0->base.pushbuf->channel); nvc0_context_unreference_resources(nvc0); #ifdef NVC0_WITH_DRAW_MODULE draw_destroy(nvc0->draw); #endif nouveau_context_destroy(&nvc0->base); }
GLboolean nouveau_context_create(gl_api api, const struct gl_config *visual, __DRIcontext *dri_ctx, unsigned major_version, unsigned minor_version, uint32_t flags, unsigned *error, void *share_ctx) { __DRIscreen *dri_screen = dri_ctx->driScreenPriv; struct nouveau_screen *screen = dri_screen->driverPrivate; struct nouveau_context *nctx; struct gl_context *ctx; /* API and flag filtering is handled in dri2CreateContextAttribs. */ (void) api; (void) flags; ctx = screen->driver->context_create(screen, visual, share_ctx); if (!ctx) { *error = __DRI_CTX_ERROR_NO_MEMORY; return GL_FALSE; } nctx = to_nouveau_context(ctx); nctx->dri_context = dri_ctx; dri_ctx->driverPrivate = ctx; _mesa_compute_version(ctx); if (ctx->VersionMajor < major_version || (ctx->VersionMajor == major_version && ctx->VersionMinor < minor_version)) { nouveau_context_destroy(dri_ctx); *error = __DRI_CTX_ERROR_BAD_VERSION; return GL_FALSE; } *error = __DRI_CTX_ERROR_SUCCESS; return GL_TRUE; }
static void nv50_destroy(struct pipe_context *pipe) { struct nv50_context *nv50 = nv50_context(pipe); if (nv50_context_screen(nv50)->cur_ctx == nv50) { nv50->base.pushbuf->kick_notify = NULL; nv50_context_screen(nv50)->cur_ctx = NULL; nouveau_pushbuf_bufctx(nv50->base.pushbuf, NULL); } /* need to flush before destroying the bufctx */ nouveau_pushbuf_kick(nv50->base.pushbuf, nv50->base.pushbuf->channel); nv50_context_unreference_resources(nv50); #ifdef NV50_WITH_DRAW_MODULE draw_destroy(nv50->draw); #endif nouveau_context_destroy(&nv50->base); }
static void nvc0_destroy(struct pipe_context *pipe) { struct nvc0_context *nvc0 = nvc0_context(pipe); if (nvc0->screen->cur_ctx == nvc0) nvc0->screen->cur_ctx = NULL; /* Unset bufctx, we don't want to revalidate any resources after the flush. * Other contexts will always set their bufctx again on action calls. */ nouveau_pushbuf_bufctx(nvc0->base.pushbuf, NULL); nouveau_pushbuf_kick(nvc0->base.pushbuf, nvc0->base.pushbuf->channel); nvc0_context_unreference_resources(nvc0); nvc0_blitctx_destroy(nvc0); #ifdef NVC0_WITH_DRAW_MODULE draw_destroy(nvc0->draw); #endif nouveau_context_destroy(&nvc0->base); }
GLboolean nouveau_context_create(gl_api api, const struct gl_config *visual, __DRIcontext *dri_ctx, unsigned major_version, unsigned minor_version, uint32_t flags, unsigned *error, void *share_ctx) { __DRIscreen *dri_screen = dri_ctx->driScreenPriv; struct nouveau_screen *screen = dri_screen->driverPrivate; struct nouveau_context *nctx; struct gl_context *ctx; switch (api) { case API_OPENGL: /* Do after-the-fact version checking (below). */ break; case API_OPENGLES: /* NV10 and NV20 can support OpenGL ES 1.0 only. Older chips * cannot do even that. */ if ((screen->device->chipset & 0xf0) == 0x00) { *error = __DRI_CTX_ERROR_BAD_API; return GL_FALSE; } else if (minor_version != 0) { *error = __DRI_CTX_ERROR_BAD_VERSION; return GL_FALSE; } break; case API_OPENGLES2: case API_OPENGL_CORE: *error = __DRI_CTX_ERROR_BAD_API; return GL_FALSE; } /* API and flag filtering is handled in dri2CreateContextAttribs. */ (void) flags; ctx = screen->driver->context_create(screen, visual, share_ctx); if (!ctx) { *error = __DRI_CTX_ERROR_NO_MEMORY; return GL_FALSE; } nctx = to_nouveau_context(ctx); nctx->dri_context = dri_ctx; dri_ctx->driverPrivate = ctx; _mesa_compute_version(ctx); if (ctx->Version < major_version * 10 + minor_version) { nouveau_context_destroy(dri_ctx); *error = __DRI_CTX_ERROR_BAD_VERSION; return GL_FALSE; } if (nouveau_bo_new(context_dev(ctx), NOUVEAU_BO_VRAM, 0, 4096, NULL, &nctx->fence)) { nouveau_context_destroy(dri_ctx); *error = __DRI_CTX_ERROR_NO_MEMORY; return GL_FALSE; } *error = __DRI_CTX_ERROR_SUCCESS; return GL_TRUE; }