From e00ae524e236afba1305150cacd634eaa1f5460b Mon Sep 17 00:00:00 2001 From: Ben Skeggs Date: Wed, 18 Mar 2009 08:22:35 +1000 Subject: nouveau: rewrite winsys in terms of drm_api, support dri2 state tracker drm_api is a set of hooks used by the dri2 state tracker, this wraps our dri1 code around the same set of hooks. Currently the dri2 build will produce nouveau_dri2.so which you'll need to install as nouveau_dri.so if you wish to try it. The dri2 state tracker doesn't make it easy for a driver to support both paths in the same binary. --- .../winsys/drm/nouveau/dri/nouveau_context.c | 118 +++++++++++++++++++++ 1 file changed, 118 insertions(+) create mode 100644 src/gallium/winsys/drm/nouveau/dri/nouveau_context.c (limited to 'src/gallium/winsys/drm/nouveau/dri/nouveau_context.c') diff --git a/src/gallium/winsys/drm/nouveau/dri/nouveau_context.c b/src/gallium/winsys/drm/nouveau/dri/nouveau_context.c new file mode 100644 index 00000000000..deb6ffcff1c --- /dev/null +++ b/src/gallium/winsys/drm/nouveau/dri/nouveau_context.c @@ -0,0 +1,118 @@ +#include
+#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include "nouveau_context.h" +#include "nouveau_screen.h" + +#include "nouveau_drmif.h" + +GLboolean +nouveau_context_create(const __GLcontextModes *glVis, + __DRIcontextPrivate *driContextPriv, + void *sharedContextPrivate) +{ + __DRIscreenPrivate *driScrnPriv = driContextPriv->driScreenPriv; + struct nouveau_screen *nv_screen = driScrnPriv->private; + struct nouveau_context *nv; + struct pipe_context *pipe; + struct st_context *st_share = NULL; + + if (sharedContextPrivate) + st_share = ((struct nouveau_context *)sharedContextPrivate)->st; + + nv = CALLOC_STRUCT(nouveau_context); + if (!nv) + return GL_FALSE; + + { + struct nouveau_device_priv *nvdev = + nouveau_device(nv_screen->device); + + nvdev->ctx = driContextPriv->hHWContext; + nvdev->lock = (drmLock *)&driScrnPriv->pSAREA->lock; + } + + pipe = drm_api_hooks.create_context(nv_screen->pscreen); + if (!pipe) { + FREE(nv); + return GL_FALSE; + } + pipe->priv = nv; + + driContextPriv->driverPrivate = nv; + nv->dri_screen = driScrnPriv; + + driParseConfigFiles(&nv->dri_option_cache, &nv_screen->option_cache, + nv->dri_screen->myNum, "nouveau"); + + nv->st = st_create_context(pipe, glVis, st_share); + return GL_TRUE; +} + +void +nouveau_context_destroy(__DRIcontextPrivate *driContextPriv) +{ + struct nouveau_context *nv = driContextPriv->driverPrivate; + + assert(nv); + + st_finish(nv->st); + st_destroy_context(nv->st); + + FREE(nv); +} + +GLboolean +nouveau_context_bind(__DRIcontextPrivate *driContextPriv, + __DRIdrawablePrivate *driDrawPriv, + __DRIdrawablePrivate *driReadPriv) +{ + struct nouveau_context *nv; + struct nouveau_framebuffer *draw, *read; + + if (!driContextPriv) { + st_make_current(NULL, NULL, NULL); + return GL_TRUE; + } + + nv = driContextPriv->driverPrivate; + draw = driDrawPriv->driverPrivate; + read = driReadPriv->driverPrivate; + + st_make_current(nv->st, draw->stfb, read->stfb); + + if ((nv->dri_drawable != driDrawPriv) || + (nv->last_stamp != driDrawPriv->lastStamp)) { + nv->dri_drawable = driDrawPriv; + st_resize_framebuffer(draw->stfb, driDrawPriv->w, + driDrawPriv->h); + nv->last_stamp = driDrawPriv->lastStamp; + } + + if (driDrawPriv != driReadPriv) { + st_resize_framebuffer(read->stfb, driReadPriv->w, + driReadPriv->h); + } + + return GL_TRUE; +} + +GLboolean +nouveau_context_unbind(__DRIcontextPrivate *driContextPriv) +{ + struct nouveau_context *nv = driContextPriv->driverPrivate; + (void)nv; + + st_flush(nv->st, 0, NULL); + return GL_TRUE; +} + -- cgit v1.2.3