1 #include <main/glheader.h>
2 #include <glapi/glthread.h>
3 #include <GL/internal/glcore.h>
6 #include <state_tracker/st_public.h>
7 #include <state_tracker/st_context.h>
8 #include <pipe/p_defines.h>
9 #include <pipe/p_context.h>
10 #include <pipe/p_screen.h>
12 #include "../common/nouveau_winsys_pipe.h"
13 #include "../common/nouveau_dri.h"
14 #include "../common/nouveau_local.h"
15 #include "nouveau_context_dri.h"
16 #include "nouveau_screen_dri.h"
19 static const struct dri_debug_control debug_control
[] = {
23 int __nouveau_debug
= 0;
27 nouveau_context_create(const __GLcontextModes
*glVis
,
28 __DRIcontextPrivate
*driContextPriv
,
29 void *sharedContextPrivate
)
31 __DRIscreenPrivate
*driScrnPriv
= driContextPriv
->driScreenPriv
;
32 struct nouveau_screen_dri
*nv_screen
= driScrnPriv
->private;
33 struct nouveau_context_dri
*nv
= CALLOC_STRUCT(nouveau_context_dri
);
34 struct st_context
*st_share
= NULL
;
35 struct nouveau_context_dri
*nv_share
= NULL
;
36 struct pipe_context
*pipe
;
38 if (sharedContextPrivate
) {
39 st_share
= ((struct nouveau_context_dri
*)sharedContextPrivate
)->st
;
40 nv_share
= st_share
->pipe
->priv
;
43 if (nouveau_context_init(&nv_screen
->base
, driContextPriv
->hHWContext
,
44 (drmLock
*)&driScrnPriv
->pSAREA
->lock
,
45 &nv_share
->base
, &nv
->base
)) {
49 pipe
= nv
->base
.nvc
->pctx
[nv
->base
.pctx_id
];
50 driContextPriv
->driverPrivate
= (void *)nv
;
51 //nv->nv_screen = nv_screen;
52 nv
->dri_screen
= driScrnPriv
;
54 driParseConfigFiles(&nv
->dri_option_cache
, &nv_screen
->option_cache
,
55 nv
->dri_screen
->myNum
, "nouveau");
57 __nouveau_debug
= driParseDebugString(getenv("NOUVEAU_DEBUG"),
61 nv
->st
= st_create_context(pipe
, glVis
, st_share
);
66 nouveau_context_destroy(__DRIcontextPrivate
*driContextPriv
)
68 struct nouveau_context_dri
*nv
= driContextPriv
->driverPrivate
;
73 st_destroy_context(nv
->st
);
75 nouveau_context_cleanup(&nv
->base
);
81 nouveau_context_bind(__DRIcontextPrivate
*driContextPriv
,
82 __DRIdrawablePrivate
*driDrawPriv
,
83 __DRIdrawablePrivate
*driReadPriv
)
85 struct nouveau_context_dri
*nv
;
86 struct nouveau_framebuffer
*draw
, *read
;
88 if (!driContextPriv
) {
89 st_make_current(NULL
, NULL
, NULL
);
93 nv
= driContextPriv
->driverPrivate
;
94 draw
= driDrawPriv
->driverPrivate
;
95 read
= driReadPriv
->driverPrivate
;
97 st_make_current(nv
->st
, draw
->stfb
, read
->stfb
);
99 if ((nv
->dri_drawable
!= driDrawPriv
) ||
100 (nv
->last_stamp
!= driDrawPriv
->lastStamp
)) {
101 nv
->dri_drawable
= driDrawPriv
;
102 st_resize_framebuffer(draw
->stfb
, driDrawPriv
->w
,
104 nv
->last_stamp
= driDrawPriv
->lastStamp
;
107 if (driDrawPriv
!= driReadPriv
) {
108 st_resize_framebuffer(read
->stfb
, driReadPriv
->w
,
116 nouveau_context_unbind(__DRIcontextPrivate
*driContextPriv
)
118 struct nouveau_context_dri
*nv
= driContextPriv
->driverPrivate
;
121 st_flush(nv
->st
, 0, NULL
);