From 2edc87eb3d7283274c3d0714e90078736f8d985e Mon Sep 17 00:00:00 2001 From: Brian Date: Mon, 5 Nov 2007 09:24:03 -0700 Subject: clean-up/re-org of intel_framebuffer code --- src/mesa/drivers/dri/intel_winsys/intel_context.c | 11 ++++---- src/mesa/drivers/dri/intel_winsys/intel_context.h | 32 +++++++++++++++++++--- src/mesa/drivers/dri/intel_winsys/intel_screen.c | 20 +++++++++++--- .../drivers/dri/intel_winsys/intel_swapbuffers.c | 8 +++--- .../drivers/dri/intel_winsys/intel_swapbuffers.h | 17 ++---------- 5 files changed, 57 insertions(+), 31 deletions(-) (limited to 'src/mesa/drivers/dri') diff --git a/src/mesa/drivers/dri/intel_winsys/intel_context.c b/src/mesa/drivers/dri/intel_winsys/intel_context.c index 292c509d196..ac2e71d6dc4 100644 --- a/src/mesa/drivers/dri/intel_winsys/intel_context.c +++ b/src/mesa/drivers/dri/intel_winsys/intel_context.c @@ -206,16 +206,17 @@ intelMakeCurrent(__DRIcontextPrivate * driContextPriv, if (driContextPriv) { struct intel_context *intel = (struct intel_context *) driContextPriv->driverPrivate; - struct st_framebuffer *draw_fb - = (struct st_framebuffer *) driDrawPriv->driverPrivate; - struct st_framebuffer *read_fb - = (struct st_framebuffer *) driReadPriv->driverPrivate; + struct intel_framebuffer *draw_fb = intel_framebuffer(driDrawPriv); + struct intel_framebuffer *read_fb = intel_framebuffer(driReadPriv); + + assert(draw_fb->stfb); + assert(read_fb->stfb); /* this is a hack so we have a valid context when the region allocation is done. Need a per-screen context? */ intel->intelScreen->dummyctxptr = intel; - st_make_current(intel->st, draw_fb, read_fb); + st_make_current(intel->st, draw_fb->stfb, read_fb->stfb); if ((intel->driDrawable != driDrawPriv) || (intel->lastStamp != driDrawPriv->lastStamp)) { diff --git a/src/mesa/drivers/dri/intel_winsys/intel_context.h b/src/mesa/drivers/dri/intel_winsys/intel_context.h index 3a61a5610fb..b2c5bfc9a22 100644 --- a/src/mesa/drivers/dri/intel_winsys/intel_context.h +++ b/src/mesa/drivers/dri/intel_winsys/intel_context.h @@ -46,6 +46,9 @@ struct st_context; #define INTEL_MAX_FIXUP 64 +/** + * Intel rendering context, contains a state tracker and intel-specific info. + */ struct intel_context { struct st_context *st; @@ -79,6 +82,22 @@ struct intel_context driOptionCache optionCache; }; + + +/** + * Intel framebuffer. + */ +struct intel_framebuffer +{ + struct st_framebuffer *stfb; + + /* other fields TBD */ + int other; +}; + + + + /* These are functions now: */ void LOCK_HARDWARE( struct intel_context *intel ); @@ -124,10 +143,7 @@ extern int __intel_debug; #define PCI_CHIP_Q33_G 0x29D2 -/*====================================================================== - * Inline conversion functions. - * These are better-typed than the macros used previously: - */ +/** Cast wrapper */ static INLINE struct intel_context * intel_context(GLcontext * ctx) { @@ -135,4 +151,12 @@ intel_context(GLcontext * ctx) } +/** Cast wrapper */ +static INLINE struct intel_framebuffer * +intel_framebuffer(__DRIdrawablePrivate * driDrawPriv) +{ + return (struct intel_framebuffer *) driDrawPriv->driverPrivate; +} + + #endif diff --git a/src/mesa/drivers/dri/intel_winsys/intel_screen.c b/src/mesa/drivers/dri/intel_winsys/intel_screen.c index cfa61fa67f8..c058c2d2140 100644 --- a/src/mesa/drivers/dri/intel_winsys/intel_screen.c +++ b/src/mesa/drivers/dri/intel_winsys/intel_screen.c @@ -29,6 +29,7 @@ #include "vblank.h" #include "xmlpool.h" +#include "intel_context.h" #include "intel_screen.h" #include "intel_batchbuffer.h" #include "intel_swapbuffers.h" @@ -280,8 +281,17 @@ intelCreateBuffer(__DRIscreenPrivate * driScrnPriv, return GL_FALSE; /* not implemented */ } else { - struct st_framebuffer *stfb = st_create_framebuffer(mesaVis); - driDrawPriv->driverPrivate = (void *) stfb; + struct intel_framebuffer *intelfb = CALLOC_STRUCT(intel_framebuffer); + if (!intelfb) + return GL_FALSE; + + intelfb->stfb = st_create_framebuffer(mesaVis); + if (!intelfb->stfb) { + free(intelfb); + return GL_FALSE; + } + + driDrawPriv->driverPrivate = (void *) intelfb; return GL_TRUE; } } @@ -289,8 +299,10 @@ intelCreateBuffer(__DRIscreenPrivate * driScrnPriv, static void intelDestroyBuffer(__DRIdrawablePrivate * driDrawPriv) { - st_unreference_framebuffer((struct st_framebuffer **) - (&(driDrawPriv->driverPrivate))); + struct intel_framebuffer *intelfb = intel_framebuffer(driDrawPriv); + assert(intelfb->stfb); + st_unreference_framebuffer(&intelfb->stfb); + free(intelfb); } diff --git a/src/mesa/drivers/dri/intel_winsys/intel_swapbuffers.c b/src/mesa/drivers/dri/intel_winsys/intel_swapbuffers.c index aef3b87bc86..7083e813b05 100644 --- a/src/mesa/drivers/dri/intel_winsys/intel_swapbuffers.c +++ b/src/mesa/drivers/dri/intel_winsys/intel_swapbuffers.c @@ -70,7 +70,7 @@ get_color_surface(struct intel_framebuffer *intel_fb, GLuint bufferIndex) { struct st_renderbuffer *strb - = st_renderbuffer(intel_fb->Base.Attachment[bufferIndex].Renderbuffer); + = st_renderbuffer(intel_fb->stfb->Base.Attachment[bufferIndex].Renderbuffer); if (strb) return strb->surface; return NULL; @@ -236,9 +236,9 @@ intelDisplaySurface(__DRIdrawablePrivate * dPriv, void intelUpdateWindowSize(__DRIdrawablePrivate *dPriv) { - struct st_framebuffer *stfb - = (struct st_framebuffer *) dPriv->driverPrivate; - st_resize_framebuffer(stfb, dPriv->w, dPriv->h); + struct intel_framebuffer *intelfb = intel_framebuffer(dPriv); + assert(intelfb->stfb); + st_resize_framebuffer(intelfb->stfb, dPriv->w, dPriv->h); } diff --git a/src/mesa/drivers/dri/intel_winsys/intel_swapbuffers.h b/src/mesa/drivers/dri/intel_winsys/intel_swapbuffers.h index b8a4ac97fbc..fca006b767c 100644 --- a/src/mesa/drivers/dri/intel_winsys/intel_swapbuffers.h +++ b/src/mesa/drivers/dri/intel_winsys/intel_swapbuffers.h @@ -25,19 +25,8 @@ * **************************************************************************/ -#ifndef INTEL_BUFFERS_H -#define INTEL_BUFFERS_H - - - -/** - * Intel framebuffer, derived from gl_framebuffer. - */ -struct intel_framebuffer -{ - struct gl_framebuffer Base; - -}; +#ifndef INTEL_SWAPBUFFERS_H +#define INTEL_SWAPBUFFERS_H extern void intelDisplaySurface(__DRIdrawablePrivate * dPriv, @@ -52,4 +41,4 @@ extern void intelCopySubBuffer(__DRIdrawablePrivate * dPriv, extern void intelUpdateWindowSize(__DRIdrawablePrivate *dPriv); -#endif /* INTEL_BUFFERS_H */ +#endif /* INTEL_SWAPBUFFERS_H */ -- cgit v1.2.3