From bafefccff8e9a56b797b988f9a5d7d72e2d51b9a Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 26 Aug 2008 16:13:39 -0600 Subject: mesa: don't check for GLSL 1.2 to advertise GL 2.1 The GLSL 1.2 features are minor... --- src/mesa/main/extensions.c | 4 ++-- src/mesa/main/getstring.c | 14 +++++--------- 2 files changed, 7 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c index 3774d56369..ddcb44f06b 100644 --- a/src/mesa/main/extensions.c +++ b/src/mesa/main/extensions.c @@ -1,8 +1,8 @@ /* * Mesa 3-D graphics library - * Version: 6.5.1 + * Version: 7.1 * - * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), diff --git a/src/mesa/main/getstring.c b/src/mesa/main/getstring.c index 48c815772d..1a82ccce59 100644 --- a/src/mesa/main/getstring.c +++ b/src/mesa/main/getstring.c @@ -85,7 +85,7 @@ compute_version(const GLcontext *ctx) ctx->Extensions.ARB_texture_non_power_of_two && ctx->Extensions.EXT_blend_equation_separate); const GLboolean ver_2_1 = (ver_2_0 && - ctx->Extensions.ARB_shading_language_120 && + /*ctx->Extensions.ARB_shading_language_120 &&*/ ctx->Extensions.EXT_pixel_buffer_object && ctx->Extensions.EXT_texture_sRGB); if (ver_2_1) @@ -121,12 +121,6 @@ _mesa_GetString( GLenum name ) static const char *vendor = "Brian Paul"; static const char *renderer = "Mesa"; -#if FEATURE_ARB_shading_language_120_foo /* support not complete! */ - static const char *sl_version = "1.20"; -#elif FEATURE_ARB_shading_language_100 - static const char *sl_version = "1.10"; -#endif - if (!ctx) return NULL; @@ -154,8 +148,10 @@ _mesa_GetString( GLenum name ) return (const GLubyte *) ctx->Extensions.String; #if FEATURE_ARB_shading_language_100 case GL_SHADING_LANGUAGE_VERSION_ARB: - if (ctx->Extensions.ARB_shading_language_100) - return (const GLubyte *) sl_version; + if (ctx->Extensions.ARB_shading_language_120) + return (const GLubyte *) "1.20"; + else if (ctx->Extensions.ARB_shading_language_100) + return (const GLubyte *) "1.10"; goto error; #endif #if FEATURE_NV_fragment_program || FEATURE_ARB_fragment_program || \ -- cgit v1.2.3 From 6138ee9de0330b9a2bf300bc0d52b471191dd1ed Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 28 Aug 2008 15:15:00 -0600 Subject: mesa: bump MAX_INSN to 350 --- src/mesa/tnl/t_vp_build.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/mesa/tnl/t_vp_build.c b/src/mesa/tnl/t_vp_build.c index d79f84f1eb..cb879da93f 100644 --- a/src/mesa/tnl/t_vp_build.c +++ b/src/mesa/tnl/t_vp_build.c @@ -235,7 +235,7 @@ static struct state_key *make_state_key( GLcontext *ctx ) */ #define PREFER_DP4 0 -#define MAX_INSN 256 +#define MAX_INSN 350 /* Use uregs to represent registers internally, translate to Mesa's * expected formats on emit. -- cgit v1.2.3 From fd81433a4efbe658db742b36c0c30c17c6effea6 Mon Sep 17 00:00:00 2001 From: "Xiang, Haihao" Date: Fri, 29 Aug 2008 09:22:41 +0800 Subject: i965: Push/pop instruction state. partial fix for #16882 --- src/mesa/drivers/dri/i965/brw_wm_glsl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/i965/brw_wm_glsl.c b/src/mesa/drivers/dri/i965/brw_wm_glsl.c index 305100f883..8dce40f25b 100644 --- a/src/mesa/drivers/dri/i965/brw_wm_glsl.c +++ b/src/mesa/drivers/dri/i965/brw_wm_glsl.c @@ -850,20 +850,20 @@ static void emit_sop(struct brw_wm_compile *c, struct brw_reg dst, src0, src1; int i; - brw_push_insn_state(p); for (i = 0; i < 4; i++) { if (mask & (1<SrcReg[0], i, 1); src1 = get_src_reg(c, &inst->SrcReg[1], i, 1); + brw_push_insn_state(p); brw_CMP(p, brw_null_reg(), cond, src0, src1); brw_set_predicate_control(p, BRW_PREDICATE_NONE); brw_MOV(p, dst, brw_imm_f(0.0)); brw_set_predicate_control(p, BRW_PREDICATE_NORMAL); brw_MOV(p, dst, brw_imm_f(1.0)); + brw_pop_insn_state(p); } } - brw_pop_insn_state(p); } static void emit_slt(struct brw_wm_compile *c, -- cgit v1.2.3 From 6073b49c7915147c28e9887039a51b8e4e2e62c5 Mon Sep 17 00:00:00 2001 From: "Xiang, Haihao" Date: Fri, 29 Aug 2008 09:27:28 +0800 Subject: i965: mask control for BREAK/CONT/DO/WHILE. partial fix fox #16882 --- src/mesa/drivers/dri/i965/brw_eu_emit.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/i965/brw_eu_emit.c b/src/mesa/drivers/dri/i965/brw_eu_emit.c index 6b97f8b170..27abdd658b 100644 --- a/src/mesa/drivers/dri/i965/brw_eu_emit.c +++ b/src/mesa/drivers/dri/i965/brw_eu_emit.c @@ -617,7 +617,7 @@ struct brw_instruction *brw_BREAK(struct brw_compile *p) brw_set_src1(insn, brw_imm_d(0x0)); insn->header.compression_control = BRW_COMPRESSION_NONE; insn->header.execution_size = BRW_EXECUTE_8; - insn->header.mask_control = BRW_MASK_DISABLE; + /* insn->header.mask_control = BRW_MASK_DISABLE; */ insn->bits3.if_else.pad0 = 0; return insn; } @@ -631,7 +631,7 @@ struct brw_instruction *brw_CONT(struct brw_compile *p) brw_set_src1(insn, brw_imm_d(0x0)); insn->header.compression_control = BRW_COMPRESSION_NONE; insn->header.execution_size = BRW_EXECUTE_8; - insn->header.mask_control = BRW_MASK_DISABLE; + /* insn->header.mask_control = BRW_MASK_DISABLE; */ insn->bits3.if_else.pad0 = 0; return insn; } @@ -655,7 +655,7 @@ struct brw_instruction *brw_DO(struct brw_compile *p, GLuint execute_size) insn->header.execution_size = execute_size; insn->header.predicate_control = BRW_PREDICATE_NONE; /* insn->header.mask_control = BRW_MASK_ENABLE; */ - insn->header.mask_control = BRW_MASK_DISABLE; + /* insn->header.mask_control = BRW_MASK_DISABLE; */ return insn; } @@ -694,7 +694,7 @@ struct brw_instruction *brw_WHILE(struct brw_compile *p, /* insn->header.mask_control = BRW_MASK_ENABLE; */ - insn->header.mask_control = BRW_MASK_DISABLE; + /* insn->header.mask_control = BRW_MASK_DISABLE; */ p->current->header.predicate_control = BRW_PREDICATE_NONE; return insn; } -- cgit v1.2.3 From 7a2ab6d05573508389b38f8f1fa261ba56062865 Mon Sep 17 00:00:00 2001 From: "Xiang, Haihao" Date: Fri, 29 Aug 2008 09:49:16 +0800 Subject: i965: force thread switch after IF/ELSE/ENDIF. partial fix for #16882. A thread switch is implicitly invoked after the issuance of an IF/ELSE/ENDIF instruction if necessary. Unfortunately it seems sometimes a forced thread switch is needed. --- src/mesa/drivers/dri/i965/brw_eu_emit.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src') diff --git a/src/mesa/drivers/dri/i965/brw_eu_emit.c b/src/mesa/drivers/dri/i965/brw_eu_emit.c index 27abdd658b..0bfbec9d14 100644 --- a/src/mesa/drivers/dri/i965/brw_eu_emit.c +++ b/src/mesa/drivers/dri/i965/brw_eu_emit.c @@ -513,6 +513,8 @@ struct brw_instruction *brw_IF(struct brw_compile *p, GLuint execute_size) insn->header.compression_control = BRW_COMPRESSION_NONE; insn->header.predicate_control = BRW_PREDICATE_NORMAL; insn->header.mask_control = BRW_MASK_ENABLE; + if (!p->single_program_flow) + insn->header.thread_control = BRW_THREAD_SWITCH; p->current->header.predicate_control = BRW_PREDICATE_NONE; @@ -538,6 +540,8 @@ struct brw_instruction *brw_ELSE(struct brw_compile *p, insn->header.compression_control = BRW_COMPRESSION_NONE; insn->header.execution_size = if_insn->header.execution_size; insn->header.mask_control = BRW_MASK_ENABLE; + if (!p->single_program_flow) + insn->header.thread_control = BRW_THREAD_SWITCH; /* Patch the if instruction to point at this instruction. */ @@ -579,6 +583,7 @@ void brw_ENDIF(struct brw_compile *p, insn->header.compression_control = BRW_COMPRESSION_NONE; insn->header.execution_size = patch_insn->header.execution_size; insn->header.mask_control = BRW_MASK_ENABLE; + insn->header.thread_control = BRW_THREAD_SWITCH; assert(patch_insn->bits3.if_else.jump_count == 0); -- cgit v1.2.3 From f56b569e9af356c11869ee49a4669bb01b75397e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristian=20H=C3=B8gsberg?= Date: Wed, 13 Aug 2008 11:46:25 -0400 Subject: DRI2: Drop sarea, implement swap buffers in the X server. --- src/glx/x11/dri2.c | 113 ++++++++---- src/glx/x11/dri2.h | 23 ++- src/glx/x11/dri2_glx.c | 128 +++++++------- src/glx/x11/dri_glx.c | 6 + src/glx/x11/glxclient.h | 5 +- src/glx/x11/glxcmds.c | 3 +- src/mesa/drivers/dri/Makefile | 2 - src/mesa/drivers/dri/common/dri_util.c | 254 ++++----------------------- src/mesa/drivers/dri/common/dri_util.h | 25 +-- src/mesa/drivers/dri/i965/brw_vtbl.c | 18 +- src/mesa/drivers/dri/intel/intel_buffers.c | 3 + src/mesa/drivers/dri/intel/intel_context.c | 160 +++++++++++++++-- src/mesa/drivers/dri/intel/intel_context.h | 1 + src/mesa/drivers/dri/intel/intel_regions.c | 7 +- src/mesa/drivers/dri/intel/intel_regions.h | 2 +- src/mesa/drivers/dri/intel/intel_screen.c | 116 +----------- src/mesa/drivers/dri/intel/intel_tex_image.c | 2 +- 17 files changed, 386 insertions(+), 482 deletions(-) (limited to 'src') diff --git a/src/glx/x11/dri2.c b/src/glx/x11/dri2.c index e7044ab424..dc60af90c1 100644 --- a/src/glx/x11/dri2.c +++ b/src/glx/x11/dri2.c @@ -122,7 +122,11 @@ Bool DRI2Connect(Display *dpy, int screen, return False; } - *sareaHandle = rep.sareaHandle; + if (rep.driverNameLength == 0 && rep.busIdLength == 0) { + UnlockDisplay(dpy); + SyncHandle(); + return False; + } *driverName = Xmalloc(rep.driverNameLength + 1); if (*driverName == NULL) { @@ -150,7 +154,7 @@ Bool DRI2Connect(Display *dpy, int screen, UnlockDisplay(dpy); SyncHandle(); - return rep.sareaHandle != 0; + return True; } Bool DRI2AuthConnection(Display *dpy, int screen, drm_magic_t magic) @@ -179,74 +183,119 @@ Bool DRI2AuthConnection(Display *dpy, int screen, drm_magic_t magic) return rep.authenticated; } -Bool DRI2CreateDrawable(Display *dpy, XID drawable, - unsigned int *handle, unsigned int *head) +void DRI2CreateDrawable(Display *dpy, XID drawable) { XExtDisplayInfo *info = DRI2FindDisplay(dpy); - xDRI2CreateDrawableReply rep; xDRI2CreateDrawableReq *req; - XextCheckExtension (dpy, info, dri2ExtensionName, False); + XextSimpleCheckExtension (dpy, info, dri2ExtensionName); LockDisplay(dpy); GetReq(DRI2CreateDrawable, req); req->reqType = info->codes->major_opcode; req->dri2ReqType = X_DRI2CreateDrawable; req->drawable = drawable; + UnlockDisplay(dpy); + SyncHandle(); +} + +DRI2Buffer *DRI2GetBuffers(Display *dpy, XID drawable, + int *width, int *height, + unsigned int *attachments, int count, + int *outCount) +{ + XExtDisplayInfo *info = DRI2FindDisplay(dpy); + xDRI2GetBuffersReply rep; + xDRI2GetBuffersReq *req; + DRI2Buffer *buffers; + xDRI2Buffer repBuffer; + CARD32 *p; + int i; + + XextCheckExtension (dpy, info, dri2ExtensionName, False); + + LockDisplay(dpy); + GetReqExtra(DRI2GetBuffers, count * 4, req); + req->reqType = info->codes->major_opcode; + req->dri2ReqType = X_DRI2GetBuffers; + req->drawable = drawable; + req->count = count; + p = (CARD32 *) &req[1]; + for (i = 0; i < count; i++) + p[i] = attachments[i]; + if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) { UnlockDisplay(dpy); SyncHandle(); - return False; + return NULL; + } + + *width = rep.width; + *height = rep.height; + *outCount = rep.count; + + buffers = Xmalloc(count * sizeof buffers[0]); + if (buffers == NULL) { + _XEatData(dpy, rep.count * sizeof repBuffer); + UnlockDisplay(dpy); + SyncHandle(); + return NULL; + } + + for (i = 0; i < rep.count; i++) { + _XReadPad(dpy, (char *) &repBuffer, sizeof repBuffer); + buffers[i].attachment = repBuffer.attachment; + buffers[i].name = repBuffer.name; + buffers[i].pitch = repBuffer.pitch; + buffers[i].cpp = repBuffer.cpp; + buffers[i].flags = repBuffer.flags; } + UnlockDisplay(dpy); SyncHandle(); - *handle = rep.handle; - *head = rep.head; - - return True; + return buffers; } -void DRI2DestroyDrawable(Display *dpy, XID drawable) +void DRI2SwapBuffers(Display *dpy, XID drawable, + int x, int y, int width, int height) { XExtDisplayInfo *info = DRI2FindDisplay(dpy); - xDRI2DestroyDrawableReq *req; + xDRI2SwapBuffersReq *req; + xDRI2SwapBuffersReply rep; XextSimpleCheckExtension (dpy, info, dri2ExtensionName); - XSync(dpy, GL_FALSE); - LockDisplay(dpy); - GetReq(DRI2DestroyDrawable, req); + GetReq(DRI2SwapBuffers, req); req->reqType = info->codes->major_opcode; - req->dri2ReqType = X_DRI2DestroyDrawable; + req->dri2ReqType = X_DRI2SwapBuffers; req->drawable = drawable; + req->x = x; + req->y = y; + req->width = width; + req->height = height; + + _XReply(dpy, (xReply *)&rep, 0, xFalse); + UnlockDisplay(dpy); SyncHandle(); } -Bool DRI2ReemitDrawableInfo(Display *dpy, XID drawable, unsigned int *head) +void DRI2DestroyDrawable(Display *dpy, XID drawable) { XExtDisplayInfo *info = DRI2FindDisplay(dpy); - xDRI2ReemitDrawableInfoReply rep; - xDRI2ReemitDrawableInfoReq *req; + xDRI2DestroyDrawableReq *req; - XextCheckExtension (dpy, info, dri2ExtensionName, False); + XextSimpleCheckExtension (dpy, info, dri2ExtensionName); + + XSync(dpy, GL_FALSE); LockDisplay(dpy); - GetReq(DRI2ReemitDrawableInfo, req); + GetReq(DRI2DestroyDrawable, req); req->reqType = info->codes->major_opcode; - req->dri2ReqType = X_DRI2ReemitDrawableInfo; + req->dri2ReqType = X_DRI2DestroyDrawable; req->drawable = drawable; - if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) { - UnlockDisplay(dpy); - SyncHandle(); - return False; - } UnlockDisplay(dpy); SyncHandle(); - - *head = rep.head; - - return True; } diff --git a/src/glx/x11/dri2.h b/src/glx/x11/dri2.h index 1dfd0448b2..e57c4ce644 100644 --- a/src/glx/x11/dri2.h +++ b/src/glx/x11/dri2.h @@ -33,6 +33,14 @@ #ifndef _DRI2_H_ #define _DRI2_H_ +typedef struct { + unsigned int attachment; + unsigned int name; + unsigned int pitch; + unsigned int cpp; + unsigned int flags; +} DRI2Buffer; + extern Bool DRI2QueryExtension(Display *display, int *eventBase, int *errorBase); extern Bool @@ -42,12 +50,17 @@ DRI2Connect(Display *display, int screen, char **driverName, char **busId, unsigned int *sareaHandle); extern Bool DRI2AuthConnection(Display *display, int screen, drm_magic_t magic); -extern Bool -DRI2CreateDrawable(Display *display, XID drawable, - unsigned int *handle, unsigned int *head); +extern void +DRI2CreateDrawable(Display *display, XID drawable); extern void DRI2DestroyDrawable(Display *display, XID handle); -extern Bool -DRI2ReemitDrawableInfo(Display *dpy, XID handle, unsigned int *head); +extern DRI2Buffer * +DRI2GetBuffers(Display *dpy, XID drawable, + int *width, int *height, + unsigned int *attachments, int count, + int *outCount); +extern void +DRI2SwapBuffers(Display *dpy, XID drawable, + int x, int y, int width, int height); #endif diff --git a/src/glx/x11/dri2_glx.c b/src/glx/x11/dri2_glx.c index 0be65bce62..c56adfa558 100644 --- a/src/glx/x11/dri2_glx.c +++ b/src/glx/x11/dri2_glx.c @@ -49,6 +49,7 @@ typedef struct __GLXDRIdisplayPrivateRec __GLXDRIdisplayPrivate; typedef struct __GLXDRIcontextPrivateRec __GLXDRIcontextPrivate; +typedef struct __GLXDRIdrawablePrivateRec __GLXDRIdrawablePrivate; struct __GLXDRIdisplayPrivateRec { __GLXDRIdisplay base; @@ -67,6 +68,13 @@ struct __GLXDRIcontextPrivateRec { __GLXscreenConfigs *psc; }; +struct __GLXDRIdrawablePrivateRec { + __GLXDRIdrawable base; + __DRIbuffer buffers[5]; + int bufferCount; + int width, height; +}; + static void dri2DestroyContext(__GLXDRIcontext *context, __GLXscreenConfigs *psc, Display *dpy) { @@ -104,7 +112,6 @@ static __GLXDRIcontext *dri2CreateContext(__GLXscreenConfigs *psc, { __GLXDRIcontextPrivate *pcp, *pcp_shared; __GLXDRIconfigPrivate *config = (__GLXDRIconfigPrivate *) mode; - const __DRIcoreExtension *core = psc->core; __DRIcontext *shared = NULL; if (shareList) { @@ -118,8 +125,8 @@ static __GLXDRIcontext *dri2CreateContext(__GLXscreenConfigs *psc, pcp->psc = psc; pcp->driContext = - (*core->createNewContext)(psc->__driScreen, - config->driConfig, shared, pcp); + (*psc->dri2->createNewContext)(psc->__driScreen, + config->driConfig, shared, pcp); gc->__driContext = pcp->driContext; if (pcp->driContext == NULL) { @@ -148,45 +155,40 @@ static __GLXDRIdrawable *dri2CreateDrawable(__GLXscreenConfigs *psc, GLXDrawable drawable, const __GLcontextModes *modes) { - __GLXDRIdrawable *pdraw; + __GLXDRIdrawablePrivate *pdraw; __GLXDRIconfigPrivate *config = (__GLXDRIconfigPrivate *) modes; - unsigned int handle, head; - const __DRIcoreExtension *core = psc->core; pdraw = Xmalloc(sizeof(*pdraw)); if (!pdraw) return NULL; - pdraw->destroyDrawable = dri2DestroyDrawable; - pdraw->xDrawable = xDrawable; - pdraw->drawable = drawable; - pdraw->psc = psc; - - fprintf(stderr, "calling DRI2CreateDrawable, XID 0x%lx, GLX ID 0x%lx\n", - xDrawable, drawable); - - if (!DRI2CreateDrawable(psc->dpy, xDrawable, &handle, &head)) { - Xfree(pdraw); - return NULL; - } + pdraw->base.destroyDrawable = dri2DestroyDrawable; + pdraw->base.xDrawable = xDrawable; + pdraw->base.drawable = drawable; + pdraw->base.psc = psc; - fprintf(stderr, "success, head 0x%x, handle 0x%x\n", head, handle); + DRI2CreateDrawable(psc->dpy, xDrawable); /* Create a new drawable */ - pdraw->driDrawable = - (*core->createNewDrawable)(psc->__driScreen, - config->driConfig, - handle, - head, - pdraw); - - if (!pdraw->driDrawable) { + pdraw->base.driDrawable = + (*psc->dri2->createNewDrawable)(psc->__driScreen, + config->driConfig, pdraw); + + if (!pdraw->base.driDrawable) { DRI2DestroyDrawable(psc->dpy, drawable); Xfree(pdraw); return NULL; } - return pdraw; + return &pdraw->base; +} + +static void dri2SwapBuffers(__GLXDRIdrawable *pdraw) +{ + __GLXDRIdrawablePrivate *priv = (__GLXDRIdrawablePrivate *) pdraw; + + DRI2SwapBuffers(pdraw->psc->dpy, pdraw->drawable, + 0, 0, priv->width, priv->height); } static void dri2DestroyScreen(__GLXscreenConfigs *psc) @@ -197,46 +199,39 @@ static void dri2DestroyScreen(__GLXscreenConfigs *psc) psc->__driScreen = NULL; } - -static void dri2ReemitDrawableInfo(__DRIdrawable *draw, unsigned int *tail, - void *loaderPrivate) +static __DRIbuffer * +dri2GetBuffers(__DRIdrawable *driDrawable, + int *width, int *height, + unsigned int *attachments, int count, + int *out_count, void *loaderPrivate) { - __GLXDRIdrawable *pdraw = loaderPrivate; - - DRI2ReemitDrawableInfo(pdraw->psc->dpy, pdraw->drawable, tail); -} - -static void dri2PostDamage(__DRIdrawable *draw, - struct drm_clip_rect *rects, - int numRects, void *loaderPrivate) -{ - XRectangle *xrects; - XserverRegion region; - __GLXDRIdrawable *glxDraw = loaderPrivate; - __GLXscreenConfigs *psc = glxDraw->psc; - Display *dpy = psc->dpy; + __GLXDRIdrawablePrivate *pdraw = loaderPrivate; + DRI2Buffer *buffers; int i; - xrects = malloc(sizeof(XRectangle) * numRects); - if (xrects == NULL) - return; - - for (i = 0; i < numRects; i++) { - xrects[i].x = rects[i].x1; - xrects[i].y = rects[i].y1; - xrects[i].width = rects[i].x2 - rects[i].x1; - xrects[i].height = rects[i].y2 - rects[i].y1; + buffers = DRI2GetBuffers(pdraw->base.psc->dpy, pdraw->base.xDrawable, + width, height, attachments, count, out_count); + pdraw->width = *width; + pdraw->height = *height; + + /* This assumes the DRI2 buffer attachment tokens matches the + * __DRIbuffer tokens. */ + for (i = 0; i < *out_count; i++) { + pdraw->buffers[i].attachment = buffers[i].attachment; + pdraw->buffers[i].name = buffers[i].name; + pdraw->buffers[i].pitch = buffers[i].pitch; + pdraw->buffers[i].cpp = buffers[i].cpp; + pdraw->buffers[i].flags = buffers[i].flags; } - region = XFixesCreateRegion(dpy, xrects, numRects); - free(xrects); - XDamageAdd(dpy, glxDraw->xDrawable, region); - XFixesDestroyRegion(dpy, region); + + Xfree(buffers); + + return pdraw->buffers; } -static const __DRIloaderExtension dri2LoaderExtension = { - { __DRI_LOADER, __DRI_LOADER_VERSION }, - dri2ReemitDrawableInfo, - dri2PostDamage +static const __DRIdri2LoaderExtension dri2LoaderExtension = { + { __DRI_DRI2_LOADER, __DRI_DRI2_LOADER_VERSION }, + dri2GetBuffers, }; static const __DRIextension *loader_extensions[] = { @@ -279,10 +274,12 @@ static __GLXDRIscreen *dri2CreateScreen(__GLXscreenConfigs *psc, int screen, for (i = 0; extensions[i]; i++) { if (strcmp(extensions[i]->name, __DRI_CORE) == 0) psc->core = (__DRIcoreExtension *) extensions[i]; + if (strcmp(extensions[i]->name, __DRI_DRI2) == 0) + psc->dri2 = (__DRIdri2Extension *) extensions[i]; } - if (psc->core == NULL) { - ErrorMessageF("core dri extension not found\n"); + if (psc->core == NULL || psc->dri2 == NULL) { + ErrorMessageF("core dri or dri2 extension not found\n"); goto handle_error; } @@ -301,7 +298,7 @@ static __GLXDRIscreen *dri2CreateScreen(__GLXscreenConfigs *psc, int screen, } psc->__driScreen = - psc->core->createNewScreen(screen, psc->fd, sareaHandle, + psc->dri2->createNewScreen(screen, psc->fd, loader_extensions, &driver_configs, psc); if (psc->__driScreen == NULL) { ErrorMessageF("failed to create dri screen\n"); @@ -316,6 +313,7 @@ static __GLXDRIscreen *dri2CreateScreen(__GLXscreenConfigs *psc, int screen, psp->destroyScreen = dri2DestroyScreen; psp->createContext = dri2CreateContext; psp->createDrawable = dri2CreateDrawable; + psp->swapBuffers = dri2SwapBuffers; Xfree(driverName); Xfree(busID); diff --git a/src/glx/x11/dri_glx.c b/src/glx/x11/dri_glx.c index 08c83a2310..39bf6c430b 100644 --- a/src/glx/x11/dri_glx.c +++ b/src/glx/x11/dri_glx.c @@ -570,6 +570,11 @@ static __GLXDRIdrawable *driCreateDrawable(__GLXscreenConfigs *psc, return pdraw; } +static void driSwapBuffers(__GLXDRIdrawable *pdraw) +{ + (*pdraw->psc->core->swapBuffers)(pdraw->driDrawable); +} + static void driDestroyScreen(__GLXscreenConfigs *psc) { /* Free the direct rendering per screen data */ @@ -641,6 +646,7 @@ static __GLXDRIscreen *driCreateScreen(__GLXscreenConfigs *psc, int screen, psp->destroyScreen = driDestroyScreen; psp->createContext = driCreateContext; psp->createDrawable = driCreateDrawable; + psp->swapBuffers = driSwapBuffers; return psp; } diff --git a/src/glx/x11/glxclient.h b/src/glx/x11/glxclient.h index e2b4218200..412511247e 100644 --- a/src/glx/x11/glxclient.h +++ b/src/glx/x11/glxclient.h @@ -123,6 +123,8 @@ struct __GLXDRIscreenRec { XID drawable, GLXDrawable glxDrawable, const __GLcontextModes *modes); + + void (*swapBuffers)(__GLXDRIdrawable *pdraw); }; struct __GLXDRIcontextRec { @@ -141,8 +143,8 @@ struct __GLXDRIdrawableRec { XID xDrawable; XID drawable; __GLXscreenConfigs *psc; - __DRIdrawable *driDrawable; GLenum textureTarget; + __DRIdrawable *driDrawable; }; /* @@ -469,6 +471,7 @@ struct __GLXscreenConfigsRec { const __DRIcoreExtension *core; const __DRIlegacyExtension *legacy; const __DRIswrastExtension *swrast; + const __DRIdri2Extension *dri2; __glxHashTable *drawHash; Display *dpy; int scr, fd; diff --git a/src/glx/x11/glxcmds.c b/src/glx/x11/glxcmds.c index 0f0cb6233a..9197130dca 100644 --- a/src/glx/x11/glxcmds.c +++ b/src/glx/x11/glxcmds.c @@ -855,7 +855,8 @@ PUBLIC void glXSwapBuffers(Display *dpy, GLXDrawable drawable) __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable, NULL); if (pdraw != NULL) { - (*pdraw->psc->core->swapBuffers)(pdraw->driDrawable); + glFlush(); + (*pdraw->psc->driScreen->swapBuffers)(pdraw); return; } #endif diff --git a/src/mesa/drivers/dri/Makefile b/src/mesa/drivers/dri/Makefile index 3b3fcf11df..eef68825bc 100644 --- a/src/mesa/drivers/dri/Makefile +++ b/src/mesa/drivers/dri/Makefile @@ -40,8 +40,6 @@ install: dri.pc $(INSTALL) -d $(DESTDIR)$(INSTALL_INC_DIR)/GL/internal $(INSTALL) -m 0644 $(TOP)/include/GL/internal/dri_interface.h \ $(DESTDIR)$(INSTALL_INC_DIR)/GL/internal - $(INSTALL) -m 0644 $(TOP)/include/GL/internal/dri_sarea.h \ - $(DESTDIR)$(INSTALL_INC_DIR)/GL/internal $(INSTALL) -d $(DESTDIR)$(INSTALL_LIB_DIR)/pkgconfig $(INSTALL) -m 0644 dri.pc $(DESTDIR)$(INSTALL_LIB_DIR)/pkgconfig diff --git a/src/mesa/drivers/dri/common/dri_util.c b/src/mesa/drivers/dri/common/dri_util.c index 93b9f458e4..ce540624a5 100644 --- a/src/mesa/drivers/dri/common/dri_util.c +++ b/src/mesa/drivers/dri/common/dri_util.c @@ -152,7 +152,6 @@ static int driUnbindContext(__DRIcontext *pcp) return GL_TRUE; } - /** * This function takes both a read buffer and a draw buffer. This is needed * for \c glXMakeCurrentReadSGI or GLX 1.3's \c glXMakeContextCurrent @@ -186,10 +185,7 @@ static int driBindContext(__DRIcontext *pcp, ** initialize the drawable information if has not been done before. */ - if (psp->dri2.enabled) { - __driParseEvents(pcp, pdp); - __driParseEvents(pcp, prp); - } else { + if (!psp->dri2.enabled) { if (!pdp->pStamp || *pdp->pStamp != pdp->lastStamp) { DRM_SPINLOCK(&psp->pSAREA->drawable_lock, psp->drawLockID); __driUtilUpdateDrawableInfo(pdp); @@ -279,139 +275,6 @@ __driUtilUpdateDrawableInfo(__DRIdrawablePrivate *pdp) DRM_SPINLOCK(&psp->pSAREA->drawable_lock, psp->drawLockID); } - -int -__driParseEvents(__DRIcontextPrivate *pcp, __DRIdrawablePrivate *pdp) -{ - __DRIscreenPrivate *psp = pdp->driScreenPriv; - __DRIDrawableConfigEvent *dc, *last_dc; - __DRIBufferAttachEvent *ba, *last_ba; - unsigned int tail, mask, *p, end, total, size, changed; - unsigned char *data; - size_t rect_size; - - /* Check for wraparound. */ - if (pcp && psp->dri2.buffer->prealloc - pdp->dri2.tail > psp->dri2.buffer->size) { - /* If prealloc overlaps into what we just parsed, the - * server overwrote it and we have to reset our tail - * pointer. */ - DRM_UNLOCK(psp->fd, psp->lock, pcp->hHWContext); - (*psp->dri2.loader->reemitDrawableInfo)(pdp, &pdp->dri2.tail, - pdp->loaderPrivate); - DRM_LIGHT_LOCK(psp->fd, psp->lock, pcp->hHWContext); - } - - total = psp->dri2.buffer->head - pdp->dri2.tail; - mask = psp->dri2.buffer->size - 1; - end = psp->dri2.buffer->head; - data = psp->dri2.buffer->data; - - changed = 0; - last_dc = NULL; - last_ba = NULL; - - for (tail = pdp->dri2.tail; tail != end; tail += size) { - p = (unsigned int *) (data + (tail & mask)); - size = DRI2_EVENT_SIZE(*p); - if (size > total || (tail & mask) + size > psp->dri2.buffer->size) { - /* illegal data, bail out. */ - fprintf(stderr, "illegal event size\n"); - break; - } - - switch (DRI2_EVENT_TYPE(*p)) { - case DRI2_EVENT_DRAWABLE_CONFIG: - dc = (__DRIDrawableConfigEvent *) p; - if (dc->drawable == pdp->dri2.drawable_id) - last_dc = dc; - break; - - case DRI2_EVENT_BUFFER_ATTACH: - ba = (__DRIBufferAttachEvent *) p; - if (ba->drawable == pdp->dri2.drawable_id && - ba->buffer.attachment == DRI_DRAWABLE_BUFFER_FRONT_LEFT) - last_ba = ba; - break; - } - } - - if (last_dc) { - if (pdp->w != last_dc->width || pdp->h != last_dc->height) - changed = 1; - - pdp->x = last_dc->x; - pdp->y = last_dc->y; - pdp->w = last_dc->width; - pdp->h = last_dc->height; - - pdp->backX = 0; - pdp->backY = 0; - pdp->numBackClipRects = 1; - pdp->pBackClipRects[0].x1 = 0; - pdp->pBackClipRects[0].y1 = 0; - pdp->pBackClipRects[0].x2 = pdp->w; - pdp->pBackClipRects[0].y2 = pdp->h; - - pdp->numClipRects = last_dc->num_rects; - _mesa_free(pdp->pClipRects); - rect_size = last_dc->num_rects * sizeof last_dc->rects[0]; - pdp->pClipRects = _mesa_malloc(rect_size); - memcpy(pdp->pClipRects, last_dc->rects, rect_size); - } - - /* We only care about the most recent drawable config. */ - if (last_dc && changed) - (*psp->DriverAPI.HandleDrawableConfig)(pdp, pcp, last_dc); - - /* Front buffer attachments are special, they typically mean that - * we're rendering to a redirected window (or a child window of a - * redirected window) and that it got resized. Resizing the root - * window on randr events is a special case of this. Other causes - * may be a window transitioning between redirected and - * non-redirected, or a window getting reparented between parents - * with different window pixmaps (eg two redirected windows). - * These events are special in that the X server allocates the - * buffer and that the buffer may be shared by other child - * windows. When our window share the window pixmap with its - * parent, drawable config events doesn't affect the front buffer. - * We only care about the last such event in the buffer; in fact, - * older events will refer to invalid buffer objects.*/ - if (last_ba) - (*psp->DriverAPI.HandleBufferAttach)(pdp, pcp, last_ba); - - /* If there was a drawable config event in the buffer and it - * changed the size of the window, all buffer auxillary buffer - * attachments prior to that are invalid (as opposed to the front - * buffer case discussed above). In that case we can start - * looking for buffer attachment after the last drawable config - * event. If there is no drawable config event in this batch of - * events, we have to assume that the last batch might have had - * one and process all buffer attach events.*/ - if (last_dc && changed) - tail = (unsigned char *) last_dc - data; - else - tail = pdp->dri2.tail; - - for ( ; tail != end; tail += size) { - ba = (__DRIBufferAttachEvent *) (data + (tail & mask)); - size = DRI2_EVENT_SIZE(ba->event_header); - - if (DRI2_EVENT_TYPE(ba->event_header) != DRI2_EVENT_BUFFER_ATTACH) - continue; - if (ba->drawable != pdp->dri2.drawable_id) - continue; - if (last_ba == ba) - continue; - - (*psp->DriverAPI.HandleBufferAttach)(pdp, pcp, ba); - changed = 1; - } - - pdp->dri2.tail = tail; - - return changed || last_ba; -} - /*@}*/ /*****************************************************************/ @@ -425,12 +288,7 @@ static void driReportDamage(__DRIdrawable *pdp, __DRIscreen *psp = pdp->driScreenPriv; /* Check that we actually have the new damage report method */ - if (psp->dri2.enabled) { - (*psp->dri2.loader->postDamage)(pdp, - pClipRects, - numClipRects, - pdp->loaderPrivate); - } else if (psp->damage) { + if (psp->damage) { /* Report the damage. Currently, all our drivers draw * directly to the front buffer, so we report the damage there * rather than to the backing storein (if any). @@ -460,9 +318,6 @@ static void driSwapBuffers(__DRIdrawable *dPriv) if (!dPriv->numClipRects) return; - if (psp->dri2.enabled) - __driParseEvents(NULL, dPriv); - psp->DriverAPI.SwapBuffers(dPriv); driReportDamage(dPriv, dPriv->pClipRects, dPriv->numClipRects); @@ -602,17 +457,17 @@ driCreateNewDrawable(__DRIscreen *psp, const __DRIconfig *config, static __DRIdrawable * -dri2CreateNewDrawable(__DRIscreen *screen, const __DRIconfig *config, - unsigned int drawable_id, unsigned int head, void *data) +dri2CreateNewDrawable(__DRIscreen *screen, + const __DRIconfig *config, + void *loaderPrivate) { __DRIdrawable *pdraw; - pdraw = driCreateNewDrawable(screen, config, 0, 0, NULL, data); + pdraw = driCreateNewDrawable(screen, config, 0, 0, NULL, loaderPrivate); if (!pdraw) return NULL; - pdraw->dri2.drawable_id = drawable_id; - pdraw->dri2.tail = head; + pdraw->pClipRects = _mesa_malloc(sizeof *pdraw->pBackClipRects); pdraw->pBackClipRects = _mesa_malloc(sizeof *pdraw->pBackClipRects); return pdraw; @@ -723,18 +578,7 @@ static __DRIcontext * dri2CreateNewContext(__DRIscreen *screen, const __DRIconfig *config, __DRIcontext *shared, void *data) { - drm_context_t hwContext; - DRM_CAS_RESULT(ret); - - /* DRI2 doesn't use kernel with context IDs, we just need an ID that's - * different from the kernel context ID to make drmLock() happy. */ - - do { - hwContext = screen->dri2.lock->next_id; - DRM_CAS(&screen->dri2.lock->next_id, hwContext, hwContext + 1, ret); - } while (ret); - - return driCreateNewContext(screen, config, 0, shared, hwContext, data); + return driCreateNewContext(screen, config, 0, shared, 0, data); } @@ -770,12 +614,7 @@ static void driDestroyScreen(__DRIscreen *psp) if (psp->DriverAPI.DestroyScreen) (*psp->DriverAPI.DestroyScreen)(psp); - if (psp->dri2.enabled) { -#ifdef TTM_API - drmBOUnmap(psp->fd, &psp->dri2.sareaBO); - drmBOUnreference(psp->fd, &psp->dri2.sareaBO); -#endif - } else { + if (!psp->dri2.enabled) { (void)drmUnmap((drmAddress)psp->pSAREA, SAREA_MAX); (void)drmUnmap((drmAddress)psp->pFB, psp->fbSize); (void)drmCloseOnce(psp->fd); @@ -798,8 +637,8 @@ setupLoaderExtensions(__DRIscreen *psp, psp->damage = (__DRIdamageExtension *) extensions[i]; if (strcmp(extensions[i]->name, __DRI_SYSTEM_TIME) == 0) psp->systemTime = (__DRIsystemTimeExtension *) extensions[i]; - if (strcmp(extensions[i]->name, __DRI_LOADER) == 0) - psp->dri2.loader = (__DRIloaderExtension *) extensions[i]; + if (strcmp(extensions[i]->name, __DRI_DRI2_LOADER) == 0) + psp->dri2.loader = (__DRIdri2LoaderExtension *) extensions[i]; } } @@ -895,19 +734,16 @@ driCreateNewScreen(int scrn, return psp; } - /** * DRI2 */ static __DRIscreen * -dri2CreateNewScreen(int scrn, int fd, unsigned int sarea_handle, +dri2CreateNewScreen(int scrn, int fd, const __DRIextension **extensions, const __DRIconfig ***driver_configs, void *data) { -#ifdef TTM_API static const __DRIextension *emptyExtensionList[] = { NULL }; __DRIscreen *psp; - unsigned int *p; drmVersionPtr version; if (driDriverAPI.InitScreen2 == NULL) @@ -932,39 +768,9 @@ dri2CreateNewScreen(int scrn, int fd, unsigned int sarea_handle, psp->myNum = scrn; psp->dri2.enabled = GL_TRUE; - if (drmBOReference(psp->fd, sarea_handle, &psp->dri2.sareaBO)) { - fprintf(stderr, "Failed to reference DRI2 sarea BO\n"); - _mesa_free(psp); - return NULL; - } - - if (drmBOMap(psp->fd, &psp->dri2.sareaBO, - DRM_BO_FLAG_READ | DRM_BO_FLAG_WRITE, 0, &psp->dri2.sarea)) { - drmBOUnreference(psp->fd, &psp->dri2.sareaBO); - _mesa_free(psp); - return NULL; - } - - p = psp->dri2.sarea; - while (DRI2_SAREA_BLOCK_TYPE(*p)) { - switch (DRI2_SAREA_BLOCK_TYPE(*p)) { - case DRI2_SAREA_BLOCK_LOCK: - psp->dri2.lock = (__DRILock *) p; - break; - case DRI2_SAREA_BLOCK_EVENT_BUFFER: - psp->dri2.buffer = (__DRIEventBuffer *) p; - break; - } - p = DRI2_SAREA_BLOCK_NEXT(p); - } - - psp->lock = (drmLock *) &psp->dri2.lock->lock; - psp->DriverAPI = driDriverAPI; *driver_configs = driDriverAPI.InitScreen2(psp); if (*driver_configs == NULL) { - drmBOUnmap(psp->fd, &psp->dri2.sareaBO); - drmBOUnreference(psp->fd, &psp->dri2.sareaBO); _mesa_free(psp); return NULL; } @@ -972,9 +778,6 @@ dri2CreateNewScreen(int scrn, int fd, unsigned int sarea_handle, psp->DriverAPI = driDriverAPI; return psp; -#else - return NULL; -#endif } static const __DRIextension **driGetExtensions(__DRIscreen *psp) @@ -982,36 +785,45 @@ static const __DRIextension **driGetExtensions(__DRIscreen *psp) return psp->extensions; } -/** Legacy DRI interface */ -const __DRIlegacyExtension driLegacyExtension = { - { __DRI_LEGACY, __DRI_LEGACY_VERSION }, - driCreateNewScreen, - driCreateNewDrawable, - driCreateNewContext -}; - -/** DRI2 interface */ +/** Core interface */ const __DRIcoreExtension driCoreExtension = { { __DRI_CORE, __DRI_CORE_VERSION }, - dri2CreateNewScreen, + NULL, driDestroyScreen, driGetExtensions, driGetConfigAttrib, driIndexConfigAttrib, - dri2CreateNewDrawable, + NULL, driDestroyDrawable, driSwapBuffers, - dri2CreateNewContext, + NULL, driCopyContext, driDestroyContext, driBindContext, driUnbindContext }; +/** Legacy DRI interface */ +const __DRIlegacyExtension driLegacyExtension = { + { __DRI_LEGACY, __DRI_LEGACY_VERSION }, + driCreateNewScreen, + driCreateNewDrawable, + driCreateNewContext, +}; + +/** Legacy DRI interface */ +const __DRIdri2Extension driDRI2Extension = { + { __DRI_DRI2, __DRI_DRI2_VERSION }, + dri2CreateNewScreen, + dri2CreateNewDrawable, + dri2CreateNewContext, +}; + /* This is the table of extensions that the loader will dlsym() for. */ PUBLIC const __DRIextension *__driDriverExtensions[] = { &driCoreExtension.base, &driLegacyExtension.base, + &driDRI2Extension.base, NULL }; diff --git a/src/mesa/drivers/dri/common/dri_util.h b/src/mesa/drivers/dri/common/dri_util.h index f126d08406..65931d3feb 100644 --- a/src/mesa/drivers/dri/common/dri_util.h +++ b/src/mesa/drivers/dri/common/dri_util.h @@ -204,16 +204,8 @@ struct __DriverAPIRec { - /* DRI2 Entry points */ + /* DRI2 Entry point */ const __DRIconfig **(*InitScreen2) (__DRIscreen * priv); - void (*HandleDrawableConfig)(__DRIdrawable *dPriv, - __DRIcontext *pcp, - __DRIDrawableConfigEvent *event); - - void (*HandleBufferAttach)(__DRIdrawable *dPriv, - __DRIcontext *pcp, - __DRIBufferAttachEvent *ba); - }; extern const struct __DriverAPIRec driDriverAPI; @@ -369,10 +361,6 @@ struct __DRIdrawableRec { * GLX_MESA_swap_control. */ unsigned int swap_interval; - struct { - unsigned int tail; - unsigned int drawable_id; - } dri2; }; /** @@ -524,13 +512,7 @@ struct __DRIscreenRec { /* Flag to indicate that this is a DRI2 screen. Many of the above * fields will not be valid or initializaed in that case. */ int enabled; -#ifdef TTM_API - drmBO sareaBO; -#endif - void *sarea; - __DRIEventBuffer *buffer; - __DRILock *lock; - __DRIloaderExtension *loader; + __DRIdri2LoaderExtension *loader; } dri2; /* The lock actually in use, old sarea or DRI2 */ @@ -544,9 +526,6 @@ __driUtilMessage(const char *f, ...); extern void __driUtilUpdateDrawableInfo(__DRIdrawable *pdp); -extern int -__driParseEvents(__DRIcontext *psp, __DRIdrawable *pdp); - extern float driCalculateSwapUsage( __DRIdrawable *dPriv, int64_t last_swap_ust, int64_t current_ust ); diff --git a/src/mesa/drivers/dri/i965/brw_vtbl.c b/src/mesa/drivers/dri/i965/brw_vtbl.c index 31e96a250a..ece01a8c9a 100644 --- a/src/mesa/drivers/dri/i965/brw_vtbl.c +++ b/src/mesa/drivers/dri/i965/brw_vtbl.c @@ -75,15 +75,27 @@ static void brw_set_draw_region( struct intel_context *intel, GLuint num_regions) { struct brw_context *brw = brw_context(&intel->ctx); + struct intel_region *old_depth_region, *old_draw_regions[MAX_DRAW_BUFFERS]; int i; + if (brw->state.depth_region != depth_region) brw->state.dirty.brw |= BRW_NEW_DEPTH_BUFFER; - for (i = 0; i < brw->state.nr_draw_regions; i++) - intel_region_release(&brw->state.draw_regions[i]); - intel_region_release(&brw->state.depth_region); + + for (i = 0; i < brw->state.nr_draw_regions; i++) { + old_draw_regions[i] = brw->state.draw_regions[i]; + brw->state.draw_regions[i] = NULL; + } + old_depth_region = brw->state.depth_region; + brw->state.depth_region = NULL; + for (i = 0; i < num_regions; i++) intel_region_reference(&brw->state.draw_regions[i], draw_regions[i]); intel_region_reference(&brw->state.depth_region, depth_region); + + for (i = 0; i < brw->state.nr_draw_regions; i++) + intel_region_release(&old_draw_regions[i]); + intel_region_release(&old_depth_region); + brw->state.nr_draw_regions = num_regions; } diff --git a/src/mesa/drivers/dri/intel/intel_buffers.c b/src/mesa/drivers/dri/intel/intel_buffers.c index 77352e6a53..3fe67462d5 100644 --- a/src/mesa/drivers/dri/intel/intel_buffers.c +++ b/src/mesa/drivers/dri/intel/intel_buffers.c @@ -618,6 +618,9 @@ intel_wait_flips(struct intel_context *intel) BUFFER_FRONT_LEFT ? BUFFER_FRONT_LEFT : BUFFER_BACK_LEFT); + if (intel->intelScreen->driScrnPriv->dri2.enabled) + return; + if (intel_fb->Base.Name == 0 && intel_rb && intel_rb->pf_pending == intel_fb->pf_seq) { GLint pf_planes = intel_fb->pf_planes; diff --git a/src/mesa/drivers/dri/intel/intel_context.c b/src/mesa/drivers/dri/intel/intel_context.c index 50c1964d87..f0ee96f18d 100644 --- a/src/mesa/drivers/dri/intel/intel_context.c +++ b/src/mesa/drivers/dri/intel/intel_context.c @@ -195,6 +195,142 @@ intelGetString(GLcontext * ctx, GLenum name) } } +void +intel_update_renderbuffers(__DRIcontext *context, __DRIdrawable *drawable) +{ + struct intel_framebuffer *intel_fb = drawable->driverPrivate; + struct intel_renderbuffer *rb; + struct intel_region *region, *depth_region; + struct intel_context *intel = context->driverPrivate; + __DRIbuffer *buffers; + __DRIscreen *screen; + int i, count; + unsigned int attachments[10]; + uint32_t name; + const char *region_name; + + if (INTEL_DEBUG & DEBUG_DRI) + fprintf(stderr, "enter %s, drawable %p\n", __func__, drawable); + + screen = intel->intelScreen->driScrnPriv; + + i = 0; + if (intel_fb->color_rb[0]) + attachments[i++] = __DRI_BUFFER_FRONT_LEFT; + if (intel_fb->color_rb[1]) + attachments[i++] = __DRI_BUFFER_BACK_LEFT; + if (intel_get_renderbuffer(&intel_fb->Base, BUFFER_DEPTH)) + attachments[i++] = __DRI_BUFFER_DEPTH; + if (intel_get_renderbuffer(&intel_fb->Base, BUFFER_STENCIL)) + attachments[i++] = __DRI_BUFFER_STENCIL; + + buffers = (*screen->dri2.loader->getBuffers)(drawable, + &drawable->w, + &drawable->h, + attachments, i, + &count, + drawable->loaderPrivate); + + drawable->x = 0; + drawable->y = 0; + drawable->backX = 0; + drawable->backY = 0; + drawable->numClipRects = 1; + drawable->pClipRects[0].x1 = 0; + drawable->pClipRects[0].y1 = 0; + drawable->pClipRects[0].x2 = drawable->w; + drawable->pClipRects[0].y2 = drawable->h; + drawable->numBackClipRects = 1; + drawable->pBackClipRects[0].x1 = 0; + drawable->pBackClipRects[0].y1 = 0; + drawable->pBackClipRects[0].x2 = drawable->w; + drawable->pBackClipRects[0].y2 = drawable->h; + + depth_region = NULL; + for (i = 0; i < count; i++) { + switch (buffers[i].attachment) { + case __DRI_BUFFER_FRONT_LEFT: + rb = intel_fb->color_rb[0]; + region_name = "dri2 front buffer"; + break; + + case __DRI_BUFFER_BACK_LEFT: + rb = intel_fb->color_rb[1]; + region_name = "dri2 back buffer"; + break; + + case __DRI_BUFFER_DEPTH: + rb = intel_get_renderbuffer(&intel_fb->Base, BUFFER_DEPTH); + region_name = "dri2 depth buffer"; + break; + + case __DRI_BUFFER_STENCIL: + rb = intel_get_renderbuffer(&intel_fb->Base, BUFFER_STENCIL); + region_name = "dri2 stencil buffer"; + break; + + case __DRI_BUFFER_ACCUM: + default: + fprintf(stderr, + "unhandled buffer attach event, attacment type %d\n", + buffers[i].attachment); + return; + } + + if (rb->region) { + intel_bo_flink(rb->region->buffer, &name); + if (name == buffers[i].name) + continue; + } + + if (INTEL_DEBUG & DEBUG_DRI) + fprintf(stderr, + "attaching buffer %d, at %d, cpp %d, pitch %d\n", + buffers[i].name, buffers[i].attachment, + buffers[i].cpp, buffers[i].pitch); + + if (buffers[i].attachment == __DRI_BUFFER_STENCIL && depth_region) { + if (INTEL_DEBUG & DEBUG_DRI) + fprintf(stderr, "(reusing depth buffer as stencil)\n"); + region = depth_region; + } + else + region = intel_region_alloc_for_handle(intel, buffers[i].cpp, + buffers[i].pitch / buffers[i].cpp, + drawable->h, + buffers[i].name, + region_name); + + if (buffers[i].attachment == __DRI_BUFFER_DEPTH) + depth_region = region; + + intel_renderbuffer_set_region(rb, region); + intel_region_release(®ion); + } + + driUpdateFramebufferSize(&intel->ctx, drawable); +} + +static void +intel_viewport(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h) +{ + struct intel_context *intel = intel_context(ctx); + __DRIcontext *driContext = intel->driContext; + + if (!driContext->driScreenPriv->dri2.enabled) + return; + + intel_update_renderbuffers(driContext, driContext->driDrawablePriv); + if (driContext->driDrawablePriv != driContext->driReadablePriv) + intel_update_renderbuffers(driContext, driContext->driReadablePriv); + + ctx->Driver.Viewport = NULL; + intel->driDrawable = driContext->driDrawablePriv; + intelWindowMoved(intel); + intel_draw_buffer(ctx, intel->ctx.DrawBuffer); + ctx->Driver.Viewport = intel_viewport; +} + /** * Extension strings exported by the intel driver. * @@ -541,6 +677,7 @@ intelInitDriverFunctions(struct dd_function_table *functions) functions->Finish = intelFinish; functions->GetString = intelGetString; functions->UpdateState = intelInvalidateState; + functions->Viewport = intel_viewport; functions->CopyColorTable = _swrast_CopyColorTable; functions->CopyColorSubTable = _swrast_CopyColorSubTable; @@ -582,6 +719,7 @@ intelInitContext(struct intel_context *intel, intel->intelScreen = intelScreen; intel->driScreen = sPriv; intel->sarea = saPriv; + intel->driContext = driContextPriv; /* Dri stuff */ intel->hHWContext = driContextPriv->hHWContext; @@ -784,6 +922,9 @@ intelMakeCurrent(__DRIcontextPrivate * driContextPriv, (struct intel_framebuffer *) driDrawPriv->driverPrivate; GLframebuffer *readFb = (GLframebuffer *) driReadPriv->driverPrivate; + intel_update_renderbuffers(driContextPriv, driDrawPriv); + if (driDrawPriv != driReadPriv) + intel_update_renderbuffers(driContextPriv, driReadPriv); /* XXX FBO temporary fix-ups! */ /* if the renderbuffers don't have regions, init them from the context */ @@ -989,18 +1130,12 @@ void LOCK_HARDWARE( struct intel_context *intel ) intel_fb->vbl_waited = vbl.reply.sequence; } - DRM_CAS(intel->driHwLock, intel->hHWContext, - (DRM_LOCK_HELD|intel->hHWContext), __ret); + if (!sPriv->dri2.enabled) { + DRM_CAS(intel->driHwLock, intel->hHWContext, + (DRM_LOCK_HELD|intel->hHWContext), __ret); - if (sPriv->dri2.enabled) { if (__ret) - drmGetLock(intel->driFd, intel->hHWContext, 0); - if (__driParseEvents(dPriv->driContextPriv, dPriv)) { - intelWindowMoved(intel); - intel_draw_buffer(&intel->ctx, intel->ctx.DrawBuffer); - } - } else if (__ret) { - intelContendedLock( intel, 0 ); + intelContendedLock( intel, 0 ); } @@ -1013,10 +1148,13 @@ void LOCK_HARDWARE( struct intel_context *intel ) */ void UNLOCK_HARDWARE( struct intel_context *intel ) { + __DRIscreen *sPriv = intel->driScreen; + intel->vtbl.note_unlock( intel ); intel->locked = 0; - DRM_UNLOCK(intel->driFd, intel->driHwLock, intel->hHWContext); + if (!sPriv->dri2.enabled) + DRM_UNLOCK(intel->driFd, intel->driHwLock, intel->hHWContext); _glthread_UNLOCK_MUTEX(lockMutex); diff --git a/src/mesa/drivers/dri/intel/intel_context.h b/src/mesa/drivers/dri/intel/intel_context.h index f9a373cf74..7381eec191 100644 --- a/src/mesa/drivers/dri/intel/intel_context.h +++ b/src/mesa/drivers/dri/intel/intel_context.h @@ -257,6 +257,7 @@ struct intel_context drmLock *driHwLock; int driFd; + __DRIcontextPrivate *driContext; __DRIdrawablePrivate *driDrawable; __DRIdrawablePrivate *driReadDrawable; __DRIscreenPrivate *driScreen; diff --git a/src/mesa/drivers/dri/intel/intel_regions.c b/src/mesa/drivers/dri/intel/intel_regions.c index ddfdce3835..c86c1034a9 100644 --- a/src/mesa/drivers/dri/intel/intel_regions.c +++ b/src/mesa/drivers/dri/intel/intel_regions.c @@ -145,12 +145,12 @@ intel_region_alloc(struct intel_context *intel, struct intel_region * intel_region_alloc_for_handle(struct intel_context *intel, GLuint cpp, GLuint pitch, GLuint height, - GLuint handle) + GLuint handle, const char *name) { struct intel_region *region; dri_bo *buffer; - buffer = intel_bo_gem_create_from_name(intel->bufmgr, "dri2 region", handle); + buffer = intel_bo_gem_create_from_name(intel->bufmgr, name, handle); region = intel_region_alloc_internal(intel, cpp, pitch, height, buffer); if (region == NULL) @@ -164,6 +164,9 @@ intel_region_alloc_for_handle(struct intel_context *intel, void intel_region_reference(struct intel_region **dst, struct intel_region *src) { + if (src) + DBG("%s %d\n", __FUNCTION__, src->refcount); + assert(*dst == NULL); if (src) { src->refcount++; diff --git a/src/mesa/drivers/dri/intel/intel_regions.h b/src/mesa/drivers/dri/intel/intel_regions.h index e5f19fbb45..1285f250a7 100644 --- a/src/mesa/drivers/dri/intel/intel_regions.h +++ b/src/mesa/drivers/dri/intel/intel_regions.h @@ -76,7 +76,7 @@ struct intel_region *intel_region_alloc(struct intel_context *intel, struct intel_region * intel_region_alloc_for_handle(struct intel_context *intel, GLuint cpp, GLuint pitch, GLuint height, - unsigned int handle); + unsigned int handle, const char *name); void intel_region_reference(struct intel_region **dst, struct intel_region *src); diff --git a/src/mesa/drivers/dri/intel/intel_screen.c b/src/mesa/drivers/dri/intel/intel_screen.c index 9ed89906d5..c193830f05 100644 --- a/src/mesa/drivers/dri/intel/intel_screen.c +++ b/src/mesa/drivers/dri/intel/intel_screen.c @@ -211,102 +211,6 @@ intelUpdateScreenFromSAREA(intelScreenPrivate * intelScreen, intelPrintSAREA(sarea); } - -/** - * DRI2 entrypoint - */ -static void -intelHandleDrawableConfig(__DRIdrawablePrivate *dPriv, - __DRIcontextPrivate *pcp, - __DRIDrawableConfigEvent *event) -{ - struct intel_framebuffer *intel_fb = dPriv->driverPrivate; - struct intel_region *region = NULL; - struct intel_renderbuffer *rb, *depth_rb, *stencil_rb; - struct intel_context *intel = pcp->driverPrivate; - int cpp, pitch; - - cpp = intel->ctx.Visual.rgbBits / 8; - pitch = ((cpp * dPriv->w + 63) & ~63) / cpp; - - rb = intel_fb->color_rb[1]; - if (rb) { - region = intel_region_alloc(intel, cpp, pitch, dPriv->h); - intel_renderbuffer_set_region(rb, region); - } - - rb = intel_fb->color_rb[2]; - if (rb) { - region = intel_region_alloc(intel, cpp, pitch, dPriv->h); - intel_renderbuffer_set_region(rb, region); - } - - depth_rb = intel_get_renderbuffer(&intel_fb->Base, BUFFER_DEPTH); - stencil_rb = intel_get_renderbuffer(&intel_fb->Base, BUFFER_STENCIL); - if (depth_rb || stencil_rb) - region = intel_region_alloc(intel, cpp, pitch, dPriv->h); - if (depth_rb) - intel_renderbuffer_set_region(depth_rb, region); - if (stencil_rb) - intel_renderbuffer_set_region(stencil_rb, region); - - /* FIXME: Tell the X server about the regions we just allocated and - * attached. */ -} - -/** - * DRI2 entrypoint - */ -static void -intelHandleBufferAttach(__DRIdrawablePrivate *dPriv, - __DRIcontextPrivate *pcp, - __DRIBufferAttachEvent *ba) -{ - struct intel_framebuffer *intel_fb = dPriv->driverPrivate; - struct intel_renderbuffer *rb; - struct intel_region *region; - struct intel_context *intel = pcp->driverPrivate; - - switch (ba->buffer.attachment) { - case DRI_DRAWABLE_BUFFER_FRONT_LEFT: - rb = intel_fb->color_rb[0]; - break; - - case DRI_DRAWABLE_BUFFER_BACK_LEFT: - rb = intel_fb->color_rb[0]; - break; - - case DRI_DRAWABLE_BUFFER_DEPTH: - rb = intel_get_renderbuffer(&intel_fb->Base, BUFFER_DEPTH); - break; - - case DRI_DRAWABLE_BUFFER_STENCIL: - rb = intel_get_renderbuffer(&intel_fb->Base, BUFFER_STENCIL); - break; - - case DRI_DRAWABLE_BUFFER_ACCUM: - default: - fprintf(stderr, "unhandled buffer attach event, attacment type %d\n", - ba->buffer.attachment); - return; - } - -#if 0 - /* FIXME: Add this so we can filter out when the X server sends us - * attachment events for the buffers we just allocated. Need to - * get the BO handle for a render buffer. */ - if (intel_renderbuffer_get_region_handle(rb) == ba->buffer.handle) - return; -#endif - - region = intel_region_alloc_for_handle(intel, ba->buffer.cpp, - ba->buffer.pitch / ba->buffer.cpp, - dPriv->h, - ba->buffer.handle); - - intel_renderbuffer_set_region(rb, region); -} - static const __DRItexOffsetExtension intelTexOffsetExtension = { { __DRI_TEX_OFFSET }, intelSetTexOffset, @@ -750,26 +654,12 @@ __DRIconfig **intelInitScreen2(__DRIscreenPrivate *psp) intelScreen->drmMinor = psp->drm_version.minor; - /* Determine chipset ID? */ + /* Determine chipset ID */ if (!intel_get_param(psp, I915_PARAM_CHIPSET_ID, &intelScreen->deviceID)) return GL_FALSE; - /* Determine if IRQs are active? */ - if (!intel_get_param(psp, I915_PARAM_IRQ_ACTIVE, - &intelScreen->irq_active)) - return GL_FALSE; - - /* Determine if batchbuffers are allowed */ - if (!intel_get_param(psp, I915_PARAM_ALLOW_BATCHBUFFER, - &intelScreen->allow_batchbuffer)) - return GL_FALSE; - - if (!intelScreen->allow_batchbuffer) { - fprintf(stderr, "batch buffer not allowed\n"); - return GL_FALSE; - } - + intelScreen->irq_active = 1; psp->extensions = intelScreenExtensions; return driConcatConfigs(intelFillInModes(psp, 16, 16, 0, 1), @@ -792,6 +682,4 @@ const struct __DriverAPIRec driDriverAPI = { .CopySubBuffer = intelCopySubBuffer, .InitScreen2 = intelInitScreen2, - .HandleDrawableConfig = intelHandleDrawableConfig, - .HandleBufferAttach = intelHandleBufferAttach, }; diff --git a/src/mesa/drivers/dri/intel/intel_tex_image.c b/src/mesa/drivers/dri/intel/intel_tex_image.c index c11687a2cf..187fcc7dcb 100644 --- a/src/mesa/drivers/dri/intel/intel_tex_image.c +++ b/src/mesa/drivers/dri/intel/intel_tex_image.c @@ -731,7 +731,7 @@ intelSetTexBuffer(__DRIcontext *pDRICtx, GLint target, __DRIdrawable *dPriv) if (!intelObj) return; - __driParseEvents(pDRICtx, dPriv); + intel_update_renderbuffers(pDRICtx, dPriv); rb = intel_fb->color_rb[0]; type = GL_BGRA; -- cgit v1.2.3 From 55270310c5040a0821fef3cfb3b620dc6c0320a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michel=20D=C3=A4nzer?= Date: Mon, 1 Sep 2008 11:43:29 +0200 Subject: Fix build by removing #include of removed dri_sarea.h. Thanks to JohnFlux on IRC for pointing out the problem. --- src/mesa/drivers/dri/common/dri_util.h | 1 - 1 file changed, 1 deletion(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/common/dri_util.h b/src/mesa/drivers/dri/common/dri_util.h index 65931d3feb..6104ac29f7 100644 --- a/src/mesa/drivers/dri/common/dri_util.h +++ b/src/mesa/drivers/dri/common/dri_util.h @@ -56,7 +56,6 @@ #include "glheader.h" #include "GL/internal/glcore.h" #include "GL/internal/dri_interface.h" -#include "GL/internal/dri_sarea.h" #define GLX_BAD_CONTEXT 5 -- cgit v1.2.3 From 418b6035133e4e10bdc46fe39af192afd087dd69 Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Tue, 2 Sep 2008 15:48:50 +0200 Subject: fix no error generated when calling glLight{if}[v] inside begin/end (bug 17408) --- src/mesa/main/light.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/mesa/main/light.c b/src/mesa/main/light.c index 6dd334e16d..94625b9f91 100644 --- a/src/mesa/main/light.c +++ b/src/mesa/main/light.c @@ -184,6 +184,7 @@ _mesa_Lightfv( GLenum light, GLenum pname, const GLfloat *params ) GET_CURRENT_CONTEXT(ctx); GLint i = (GLint) (light - GL_LIGHT0); GLfloat temp[4]; + ASSERT_OUTSIDE_BEGIN_END(ctx); if (i < 0 || i >= (GLint) ctx->Const.MaxLights) { _mesa_error( ctx, GL_INVALID_ENUM, "glLight(light=0x%x)", light ); -- cgit v1.2.3 From 0fd1a8c4a1201f3508cb6a98dc1c66ab9ebd919f Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 2 Sep 2008 18:10:34 -0600 Subject: fix BUFFER_DEPTH/BUFFER_ACCUM mix-up --- src/mesa/main/framebuffer.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/mesa/main/framebuffer.c b/src/mesa/main/framebuffer.c index d62af98f8a..a4f7e45f67 100644 --- a/src/mesa/main/framebuffer.c +++ b/src/mesa/main/framebuffer.c @@ -1,8 +1,8 @@ /* * Mesa 3-D graphics library - * Version: 6.5.1 + * Version: 7.2 * - * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -491,13 +491,13 @@ _mesa_update_framebuffer_visual(struct gl_framebuffer *fb) if (fb->Attachment[BUFFER_ACCUM].Renderbuffer) { fb->Visual.haveAccumBuffer = GL_TRUE; fb->Visual.accumRedBits - = fb->Attachment[BUFFER_DEPTH].Renderbuffer->RedBits; + = fb->Attachment[BUFFER_ACCUM].Renderbuffer->RedBits; fb->Visual.accumGreenBits - = fb->Attachment[BUFFER_DEPTH].Renderbuffer->GreenBits; + = fb->Attachment[BUFFER_ACCUM].Renderbuffer->GreenBits; fb->Visual.accumBlueBits - = fb->Attachment[BUFFER_DEPTH].Renderbuffer->BlueBits; + = fb->Attachment[BUFFER_ACCUM].Renderbuffer->BlueBits; fb->Visual.accumAlphaBits - = fb->Attachment[BUFFER_DEPTH].Renderbuffer->AlphaBits; + = fb->Attachment[BUFFER_ACCUM].Renderbuffer->AlphaBits; } compute_depth_max(fb); -- cgit v1.2.3 From 3bb2a24921af0ec419afc928ee5b279982aa01ea Mon Sep 17 00:00:00 2001 From: "Xiang, Haihao" Date: Wed, 3 Sep 2008 14:47:36 +0800 Subject: intel: Fix a crash if dri2 is disabled. --- src/mesa/drivers/dri/intel/intel_context.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/intel/intel_context.c b/src/mesa/drivers/dri/intel/intel_context.c index f0ee96f18d..2975e4c0f0 100644 --- a/src/mesa/drivers/dri/intel/intel_context.c +++ b/src/mesa/drivers/dri/intel/intel_context.c @@ -921,14 +921,14 @@ intelMakeCurrent(__DRIcontextPrivate * driContextPriv, struct intel_framebuffer *intel_fb = (struct intel_framebuffer *) driDrawPriv->driverPrivate; GLframebuffer *readFb = (GLframebuffer *) driReadPriv->driverPrivate; - - intel_update_renderbuffers(driContextPriv, driDrawPriv); - if (driDrawPriv != driReadPriv) - intel_update_renderbuffers(driContextPriv, driReadPriv); - - /* XXX FBO temporary fix-ups! */ - /* if the renderbuffers don't have regions, init them from the context */ - if (!driContextPriv->driScreenPriv->dri2.enabled) { + + if (driContextPriv->driScreenPriv->dri2.enabled) { + intel_update_renderbuffers(driContextPriv, driDrawPriv); + if (driDrawPriv != driReadPriv) + intel_update_renderbuffers(driContextPriv, driReadPriv); + } else { + /* XXX FBO temporary fix-ups! */ + /* if the renderbuffers don't have regions, init them from the context */ struct intel_renderbuffer *irbDepth = intel_get_renderbuffer(&intel_fb->Base, BUFFER_DEPTH); struct intel_renderbuffer *irbStencil -- cgit v1.2.3 From e32721c46a713f55a8fd70e61f9cb066eeb69211 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 3 Sep 2008 12:36:43 +0100 Subject: intel: Fix refcounting on depth buffer initialization in DRI2. (Reverts a change to work around the problem on 965). --- src/mesa/drivers/dri/i965/brw_vtbl.c | 18 +++--------------- src/mesa/drivers/dri/intel/intel_context.c | 2 +- 2 files changed, 4 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/i965/brw_vtbl.c b/src/mesa/drivers/dri/i965/brw_vtbl.c index ece01a8c9a..31e96a250a 100644 --- a/src/mesa/drivers/dri/i965/brw_vtbl.c +++ b/src/mesa/drivers/dri/i965/brw_vtbl.c @@ -75,27 +75,15 @@ static void brw_set_draw_region( struct intel_context *intel, GLuint num_regions) { struct brw_context *brw = brw_context(&intel->ctx); - struct intel_region *old_depth_region, *old_draw_regions[MAX_DRAW_BUFFERS]; int i; - if (brw->state.depth_region != depth_region) brw->state.dirty.brw |= BRW_NEW_DEPTH_BUFFER; - - for (i = 0; i < brw->state.nr_draw_regions; i++) { - old_draw_regions[i] = brw->state.draw_regions[i]; - brw->state.draw_regions[i] = NULL; - } - old_depth_region = brw->state.depth_region; - brw->state.depth_region = NULL; - + for (i = 0; i < brw->state.nr_draw_regions; i++) + intel_region_release(&brw->state.draw_regions[i]); + intel_region_release(&brw->state.depth_region); for (i = 0; i < num_regions; i++) intel_region_reference(&brw->state.draw_regions[i], draw_regions[i]); intel_region_reference(&brw->state.depth_region, depth_region); - - for (i = 0; i < brw->state.nr_draw_regions; i++) - intel_region_release(&old_draw_regions[i]); - intel_region_release(&old_depth_region); - brw->state.nr_draw_regions = num_regions; } diff --git a/src/mesa/drivers/dri/intel/intel_context.c b/src/mesa/drivers/dri/intel/intel_context.c index 2975e4c0f0..c2ad5a0423 100644 --- a/src/mesa/drivers/dri/intel/intel_context.c +++ b/src/mesa/drivers/dri/intel/intel_context.c @@ -292,7 +292,7 @@ intel_update_renderbuffers(__DRIcontext *context, __DRIdrawable *drawable) if (buffers[i].attachment == __DRI_BUFFER_STENCIL && depth_region) { if (INTEL_DEBUG & DEBUG_DRI) fprintf(stderr, "(reusing depth buffer as stencil)\n"); - region = depth_region; + intel_region_reference(®ion, depth_region); } else region = intel_region_alloc_for_handle(intel, buffers[i].cpp, -- cgit v1.2.3 From a04aeea5c016530d7371e032438a0a8fa2c0d7f6 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 3 Sep 2008 16:13:18 +0100 Subject: intel: Fix prototype warning. --- src/mesa/drivers/dri/intel/intel_context.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/mesa/drivers/dri/intel/intel_context.h b/src/mesa/drivers/dri/intel/intel_context.h index 7381eec191..04a20278d1 100644 --- a/src/mesa/drivers/dri/intel/intel_context.h +++ b/src/mesa/drivers/dri/intel/intel_context.h @@ -493,6 +493,8 @@ extern int intel_translate_stencil_op(GLenum op); extern int intel_translate_blend_factor(GLenum factor); extern int intel_translate_logic_op(GLenum opcode); +void intel_update_renderbuffers(__DRIcontext *context, + __DRIdrawable *drawable); /*====================================================================== * Inline conversion functions. -- cgit v1.2.3 From dc44bb8e9208680379b31df01b4499c3a3bde5cb Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Thu, 4 Sep 2008 10:35:01 +0800 Subject: mesa: Support for MESA_FORMAT_S8_Z24 texture cherry-picked from gallium-0.1 --- src/mesa/main/texformat.c | 24 +++++++++++++ src/mesa/main/texformat.h | 2 ++ src/mesa/main/texformat_tmp.h | 26 ++++++++++++++ src/mesa/main/texstore.c | 81 +++++++++++++++++++++++++++++++++++++++++++ src/mesa/main/texstore.h | 1 + 5 files changed, 134 insertions(+) (limited to 'src') diff --git a/src/mesa/main/texformat.c b/src/mesa/main/texformat.c index acc268e622..a32ad6380c 100644 --- a/src/mesa/main/texformat.c +++ b/src/mesa/main/texformat.c @@ -1207,6 +1207,30 @@ const struct gl_texture_format _mesa_texformat_z24_s8 = { store_texel_z24_s8 /* StoreTexel */ }; +const struct gl_texture_format _mesa_texformat_s8_z24 = { + MESA_FORMAT_S8_Z24, /* MesaFormat */ + GL_DEPTH_STENCIL_EXT, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED_ARB, /* DataType */ + 0, /* RedBits */ + 0, /* GreenBits */ + 0, /* BlueBits */ + 0, /* AlphaBits */ + 0, /* LuminanceBits */ + 0, /* IntensityBits */ + 0, /* IndexBits */ + 24, /* DepthBits */ + 8, /* StencilBits */ + 4, /* TexelBytes */ + _mesa_texstore_s8_z24, /* StoreTexImageFunc */ + NULL, /* FetchTexel1D */ + NULL, /* FetchTexel2D */ + NULL, /* FetchTexel3D */ + fetch_texel_1d_f_s8_z24, /* FetchTexel1Df */ + fetch_texel_2d_f_s8_z24, /* FetchTexel2Df */ + fetch_texel_3d_f_s8_z24, /* FetchTexel3Df */ + store_texel_s8_z24 /* StoreTexel */ +}; + const struct gl_texture_format _mesa_texformat_z16 = { MESA_FORMAT_Z16, /* MesaFormat */ GL_DEPTH_COMPONENT, /* BaseFormat */ diff --git a/src/mesa/main/texformat.h b/src/mesa/main/texformat.h index 82023b946d..f5f851ca21 100644 --- a/src/mesa/main/texformat.h +++ b/src/mesa/main/texformat.h @@ -84,6 +84,7 @@ enum _format { MESA_FORMAT_YCBCR, /* YYYY YYYY UorV UorV */ MESA_FORMAT_YCBCR_REV, /* UorV UorV YYYY YYYY */ MESA_FORMAT_Z24_S8, /* ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ SSSS SSSS */ + MESA_FORMAT_S8_Z24, /* SSSS SSSS ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ */ MESA_FORMAT_Z16, /* ZZZZ ZZZZ ZZZZ ZZZZ */ MESA_FORMAT_Z32, /* ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ */ /*@}*/ @@ -211,6 +212,7 @@ extern const struct gl_texture_format _mesa_texformat_l8; extern const struct gl_texture_format _mesa_texformat_i8; extern const struct gl_texture_format _mesa_texformat_ci8; extern const struct gl_texture_format _mesa_texformat_z24_s8; +extern const struct gl_texture_format _mesa_texformat_s8_z24; extern const struct gl_texture_format _mesa_texformat_z16; extern const struct gl_texture_format _mesa_texformat_z32; /*@}*/ diff --git a/src/mesa/main/texformat_tmp.h b/src/mesa/main/texformat_tmp.h index 99785da1a0..63939f4011 100644 --- a/src/mesa/main/texformat_tmp.h +++ b/src/mesa/main/texformat_tmp.h @@ -1363,6 +1363,32 @@ static void store_texel_z24_s8(struct gl_texture_image *texImage, #endif +/* MESA_TEXFORMAT_S8_Z24 ***************************************************/ + +static void FETCH(f_s8_z24)( const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel ) +{ + /* only return Z, not stencil data */ + const GLuint *src = TEXEL_ADDR(GLuint, texImage, i, j, k, 1); + const GLfloat scale = 1.0F / (GLfloat) 0xffffff; + texel[0] = ((*src) & 0x00ffffff) * scale; + ASSERT(texImage->TexFormat->MesaFormat == MESA_FORMAT_S8_Z24); + ASSERT(texel[0] >= 0.0F); + ASSERT(texel[0] <= 1.0F); +} + +#if DIM == 3 +static void store_texel_s8_z24(struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, const void *texel) +{ + /* only store Z, not stencil */ + GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1); + GLfloat depth = *((GLfloat *) texel); + GLuint zi = (GLuint) (depth * 0xffffff); + *dst = zi | (*dst & 0xff000000); +} +#endif + #undef TEXEL_ADDR #undef DIM diff --git a/src/mesa/main/texstore.c b/src/mesa/main/texstore.c index 25381e32dc..1efaf97fb6 100644 --- a/src/mesa/main/texstore.c +++ b/src/mesa/main/texstore.c @@ -2445,6 +2445,87 @@ _mesa_texstore_z24_s8(TEXSTORE_PARAMS) } +/** + * Store a combined depth/stencil texture image. + */ +GLboolean +_mesa_texstore_s8_z24(TEXSTORE_PARAMS) +{ + const GLuint depthScale = 0xffffff; + const GLint srcRowStride + = _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType) + / sizeof(GLuint); + GLint img, row; + + ASSERT(dstFormat == &_mesa_texformat_s8_z24); + ASSERT(srcFormat == GL_DEPTH_STENCIL_EXT || srcFormat == GL_DEPTH_COMPONENT); + ASSERT(srcFormat != GL_DEPTH_STENCIL_EXT || srcType == GL_UNSIGNED_INT_24_8_EXT); + + /* Incase we only upload depth we need to preserve the stencil */ + if (srcFormat == GL_DEPTH_COMPONENT) { + for (img = 0; img < srcDepth; img++) { + GLuint *dstRow = (GLuint *) dstAddr + + dstImageOffsets[dstZoffset + img] + + dstYoffset * dstRowStride / sizeof(GLuint) + + dstXoffset; + const GLuint *src + = (const GLuint *) _mesa_image_address(dims, srcPacking, srcAddr, + srcWidth, srcHeight, + srcFormat, srcType, + img, 0, 0); + for (row = 0; row < srcHeight; row++) { + GLuint depth[MAX_WIDTH]; + GLint i; + _mesa_unpack_depth_span(ctx, srcWidth, + GL_UNSIGNED_INT, /* dst type */ + depth, /* dst addr */ + depthScale, + srcType, src, srcPacking); + + for (i = 0; i < srcWidth; i++) + dstRow[i] = depth[i] | (dstRow[i] & 0xFF000000); + + src += srcRowStride; + dstRow += dstRowStride / sizeof(GLuint); + } + } + } else { + for (img = 0; img < srcDepth; img++) { + GLuint *dstRow = (GLuint *) dstAddr + + dstImageOffsets[dstZoffset + img] + + dstYoffset * dstRowStride / sizeof(GLuint) + + dstXoffset; + const GLuint *src + = (const GLuint *) _mesa_image_address(dims, srcPacking, srcAddr, + srcWidth, srcHeight, + srcFormat, srcType, + img, 0, 0); + for (row = 0; row < srcHeight; row++) { + GLubyte stencil[MAX_WIDTH]; + GLint i; + /* the 24 depth bits will be in the high position: */ + _mesa_unpack_depth_span(ctx, srcWidth, + GL_UNSIGNED_INT, /* dst type */ + dstRow, /* dst addr */ + depthScale, + srcType, src, srcPacking); + /* get the 8-bit stencil values */ + _mesa_unpack_stencil_span(ctx, srcWidth, + GL_UNSIGNED_BYTE, /* dst type */ + stencil, /* dst addr */ + srcType, src, srcPacking, + ctx->_ImageTransferState); + /* merge stencil values into depth values */ + for (i = 0; i < srcWidth; i++) + dstRow[i] = stencil[i] << 24; + + src += srcRowStride; + dstRow += dstRowStride / sizeof(GLuint); + } + } + } + return GL_TRUE; +} /** * Store an image in any of the formats: diff --git a/src/mesa/main/texstore.h b/src/mesa/main/texstore.h index 5128bc5827..c9edf14dbc 100644 --- a/src/mesa/main/texstore.h +++ b/src/mesa/main/texstore.h @@ -57,6 +57,7 @@ extern GLboolean _mesa_texstore_a8(TEXSTORE_PARAMS); extern GLboolean _mesa_texstore_ci8(TEXSTORE_PARAMS); extern GLboolean _mesa_texstore_ycbcr(TEXSTORE_PARAMS); extern GLboolean _mesa_texstore_z24_s8(TEXSTORE_PARAMS); +extern GLboolean _mesa_texstore_s8_z24(TEXSTORE_PARAMS); extern GLboolean _mesa_texstore_z16(TEXSTORE_PARAMS); extern GLboolean _mesa_texstore_z32(TEXSTORE_PARAMS); extern GLboolean _mesa_texstore_rgba_float32(TEXSTORE_PARAMS); -- cgit v1.2.3 From 218df7f9c53db90abf3a6590f77c8e9e49aeedf5 Mon Sep 17 00:00:00 2001 From: "Xiang, Haihao" Date: Thu, 4 Sep 2008 11:32:52 +0800 Subject: mesa: merge stencil values into depth values for MESA_FORMAT_S8_Z24 --- src/mesa/main/texstore.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/mesa/main/texstore.c b/src/mesa/main/texstore.c index 1efaf97fb6..e6eb1e2cd9 100644 --- a/src/mesa/main/texstore.c +++ b/src/mesa/main/texstore.c @@ -2503,7 +2503,7 @@ _mesa_texstore_s8_z24(TEXSTORE_PARAMS) for (row = 0; row < srcHeight; row++) { GLubyte stencil[MAX_WIDTH]; GLint i; - /* the 24 depth bits will be in the high position: */ + /* the 24 depth bits will be in the low position: */ _mesa_unpack_depth_span(ctx, srcWidth, GL_UNSIGNED_INT, /* dst type */ dstRow, /* dst addr */ @@ -2517,7 +2517,7 @@ _mesa_texstore_s8_z24(TEXSTORE_PARAMS) ctx->_ImageTransferState); /* merge stencil values into depth values */ for (i = 0; i < srcWidth; i++) - dstRow[i] = stencil[i] << 24; + dstRow[i] |= stencil[i] << 24; src += srcRowStride; dstRow += dstRowStride / sizeof(GLuint); -- cgit v1.2.3 From 0adfd1021035e90995a25ec5f20b736e55075d92 Mon Sep 17 00:00:00 2001 From: "Xiang, Haihao" Date: Thu, 4 Sep 2008 11:35:15 +0800 Subject: intel: Fix depth_stencil texture. --- src/mesa/drivers/dri/i915/i915_texstate.c | 2 +- src/mesa/drivers/dri/i965/brw_wm_surface_state.c | 2 +- src/mesa/drivers/dri/intel/intel_tex_format.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/i915/i915_texstate.c b/src/mesa/drivers/dri/i915/i915_texstate.c index 69c1e0755e..1b1122cd8a 100644 --- a/src/mesa/drivers/dri/i915/i915_texstate.c +++ b/src/mesa/drivers/dri/i915/i915_texstate.c @@ -78,7 +78,7 @@ translate_texture_format(GLuint mesa_format, GLenum DepthMode) return (MAPSURF_COMPRESSED | MT_COMPRESS_DXT2_3); case MESA_FORMAT_RGBA_DXT5: return (MAPSURF_COMPRESSED | MT_COMPRESS_DXT4_5); - case MESA_FORMAT_Z24_S8: + case MESA_FORMAT_S8_Z24: return (MAPSURF_32BIT | MT_32BIT_xI824); default: fprintf(stderr, "%s: bad image format %x\n", __FUNCTION__, mesa_format); diff --git a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c index af1401b34b..493d2b182c 100644 --- a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c +++ b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c @@ -138,7 +138,7 @@ static GLuint translate_tex_format( GLuint mesa_format, GLenum depth_mode ) case MESA_FORMAT_SRGB_DXT1: return BRW_SURFACEFORMAT_BC1_UNORM_SRGB; - case MESA_FORMAT_Z24_S8: + case MESA_FORMAT_S8_Z24: return BRW_SURFACEFORMAT_I24X8_UNORM; default: diff --git a/src/mesa/drivers/dri/intel/intel_tex_format.c b/src/mesa/drivers/dri/intel/intel_tex_format.c index 349a29bd71..8ae80e1601 100644 --- a/src/mesa/drivers/dri/intel/intel_tex_format.c +++ b/src/mesa/drivers/dri/intel/intel_tex_format.c @@ -138,7 +138,7 @@ intelChooseTextureFormat(GLcontext * ctx, GLint internalFormat, case GL_DEPTH_STENCIL_EXT: case GL_DEPTH24_STENCIL8_EXT: - return &_mesa_texformat_z24_s8; + return &_mesa_texformat_s8_z24; #ifndef I915 case GL_SRGB_EXT: -- cgit v1.2.3 From 37c74af01ce52b603f565a6c8a9094500d5cb87a Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 4 Sep 2008 14:58:02 -0600 Subject: mesa: improved gl_buffer_object reference counting Use new _mesa_reference_buffer_object() function wherever possible. Fixes buffer object/display list crash reported in ParaView. --- src/mesa/main/arrayobj.c | 31 ++++--- src/mesa/main/attrib.c | 87 +++++++++++--------- src/mesa/main/bufferobj.c | 188 +++++++++++++++++++++---------------------- src/mesa/main/bufferobj.h | 11 +-- src/mesa/main/varray.c | 15 ++-- src/mesa/vbo/vbo_exec_api.c | 8 +- src/mesa/vbo/vbo_exec_draw.c | 26 ++++-- src/mesa/vbo/vbo_save.c | 16 ++-- src/mesa/vbo/vbo_save_api.c | 17 +++- src/mesa/vbo/vbo_save_draw.c | 28 +++++-- 10 files changed, 241 insertions(+), 186 deletions(-) (limited to 'src') diff --git a/src/mesa/main/arrayobj.c b/src/mesa/main/arrayobj.c index f08f99d8e1..0bc582602e 100644 --- a/src/mesa/main/arrayobj.c +++ b/src/mesa/main/arrayobj.c @@ -1,8 +1,8 @@ /* * Mesa 3-D graphics library - * Version: 6.5 + * Version: 7.2 * - * Copyright (C) 1999-2004 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. * (C) Copyright IBM Corporation 2006 * * Permission is hereby granted, free of charge, to any person obtaining a @@ -210,6 +210,15 @@ _mesa_remove_array_object( GLcontext *ctx, struct gl_array_object *obj ) } +static void +unbind_buffer_object( GLcontext *ctx, struct gl_buffer_object *bufObj ) +{ + if (bufObj != ctx->Array.NullBufferObj) { + _mesa_reference_buffer_object(ctx, &bufObj, NULL); + } +} + + /**********************************************************************/ /* API Functions */ /**********************************************************************/ @@ -311,18 +320,18 @@ _mesa_DeleteVertexArraysAPPLE(GLsizei n, const GLuint *ids) /* Unbind any buffer objects that might be bound to arrays in * this array object. */ - _mesa_unbind_buffer_object( ctx, obj->Vertex.BufferObj ); - _mesa_unbind_buffer_object( ctx, obj->Normal.BufferObj ); - _mesa_unbind_buffer_object( ctx, obj->Color.BufferObj ); - _mesa_unbind_buffer_object( ctx, obj->SecondaryColor.BufferObj ); - _mesa_unbind_buffer_object( ctx, obj->FogCoord.BufferObj ); - _mesa_unbind_buffer_object( ctx, obj->Index.BufferObj ); + unbind_buffer_object( ctx, obj->Vertex.BufferObj ); + unbind_buffer_object( ctx, obj->Normal.BufferObj ); + unbind_buffer_object( ctx, obj->Color.BufferObj ); + unbind_buffer_object( ctx, obj->SecondaryColor.BufferObj ); + unbind_buffer_object( ctx, obj->FogCoord.BufferObj ); + unbind_buffer_object( ctx, obj->Index.BufferObj ); for (i = 0; i < MAX_TEXTURE_UNITS; i++) { - _mesa_unbind_buffer_object( ctx, obj->TexCoord[i].BufferObj ); + unbind_buffer_object( ctx, obj->TexCoord[i].BufferObj ); } - _mesa_unbind_buffer_object( ctx, obj->EdgeFlag.BufferObj ); + unbind_buffer_object( ctx, obj->EdgeFlag.BufferObj ); for (i = 0; i < VERT_ATTRIB_MAX; i++) { - _mesa_unbind_buffer_object( ctx, obj->VertexAttrib[i].BufferObj ); + unbind_buffer_object( ctx, obj->VertexAttrib[i].BufferObj ); } #endif diff --git a/src/mesa/main/attrib.c b/src/mesa/main/attrib.c index c3c1f927fd..94475b981d 100644 --- a/src/mesa/main/attrib.c +++ b/src/mesa/main/attrib.c @@ -1,8 +1,8 @@ /* * Mesa 3-D graphics library - * Version: 7.1 + * Version: 7.2 * - * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -1274,6 +1274,29 @@ adjust_buffer_object_ref_counts(struct gl_array_attrib *array, GLint step) } +/** + * Copy gl_pixelstore_attrib from src to dst, updating buffer + * object refcounts. + */ +static void +copy_pixelstore(GLcontext *ctx, + struct gl_pixelstore_attrib *dst, + const struct gl_pixelstore_attrib *src) +{ + dst->Alignment = src->Alignment; + dst->RowLength = src->RowLength; + dst->SkipPixels = src->SkipPixels; + dst->SkipRows = src->SkipRows; + dst->ImageHeight = src->ImageHeight; + dst->SkipImages = src->SkipImages; + dst->SwapBytes = src->SwapBytes; + dst->LsbFirst = src->LsbFirst; + dst->ClientStorage = src->ClientStorage; + dst->Invert = src->Invert; + _mesa_reference_buffer_object(ctx, &dst->BufferObj, src->BufferObj); +} + + #define GL_CLIENT_PACK_BIT (1<<20) #define GL_CLIENT_UNPACK_BIT (1<<21) @@ -1292,31 +1315,29 @@ _mesa_PushClientAttrib(GLbitfield mask) return; } - /* Build linked list of attribute nodes which save all attribute */ - /* groups specified by the mask. */ + /* Build linked list of attribute nodes which save all attribute + * groups specified by the mask. + */ head = NULL; if (mask & GL_CLIENT_PIXEL_STORE_BIT) { struct gl_pixelstore_attrib *attr; -#if FEATURE_EXT_pixel_buffer_object - ctx->Pack.BufferObj->RefCount++; - ctx->Unpack.BufferObj->RefCount++; -#endif /* packing attribs */ - attr = MALLOC_STRUCT( gl_pixelstore_attrib ); - MEMCPY( attr, &ctx->Pack, sizeof(struct gl_pixelstore_attrib) ); + attr = CALLOC_STRUCT( gl_pixelstore_attrib ); + copy_pixelstore(ctx, attr, &ctx->Pack); newnode = new_attrib_node( GL_CLIENT_PACK_BIT ); newnode->data = attr; newnode->next = head; head = newnode; /* unpacking attribs */ attr = MALLOC_STRUCT( gl_pixelstore_attrib ); - MEMCPY( attr, &ctx->Unpack, sizeof(struct gl_pixelstore_attrib) ); + copy_pixelstore(ctx, attr, &ctx->Unpack); newnode = new_attrib_node( GL_CLIENT_UNPACK_BIT ); newnode->data = attr; newnode->next = head; head = newnode; } + if (mask & GL_CLIENT_VERTEX_ARRAY_BIT) { struct gl_array_attrib *attr; struct gl_array_object *obj; @@ -1353,7 +1374,7 @@ _mesa_PushClientAttrib(GLbitfield mask) void GLAPIENTRY _mesa_PopClientAttrib(void) { - struct gl_attrib_node *attr, *next; + struct gl_attrib_node *node, *next; GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); @@ -1364,37 +1385,31 @@ _mesa_PopClientAttrib(void) } ctx->ClientAttribStackDepth--; - attr = ctx->ClientAttribStack[ctx->ClientAttribStackDepth]; + node = ctx->ClientAttribStack[ctx->ClientAttribStackDepth]; - while (attr) { - switch (attr->kind) { + while (node) { + switch (node->kind) { case GL_CLIENT_PACK_BIT: -#if FEATURE_EXT_pixel_buffer_object - ctx->Pack.BufferObj->RefCount--; - if (ctx->Pack.BufferObj->RefCount <= 0) { - _mesa_remove_buffer_object( ctx, ctx->Pack.BufferObj ); - (*ctx->Driver.DeleteBuffer)( ctx, ctx->Pack.BufferObj ); + { + struct gl_pixelstore_attrib *store = + (struct gl_pixelstore_attrib *) node->data; + copy_pixelstore(ctx, &ctx->Pack, store); + _mesa_reference_buffer_object(ctx, &store->BufferObj, NULL); } -#endif - MEMCPY( &ctx->Pack, attr->data, - sizeof(struct gl_pixelstore_attrib) ); ctx->NewState |= _NEW_PACKUNPACK; break; case GL_CLIENT_UNPACK_BIT: -#if FEATURE_EXT_pixel_buffer_object - ctx->Unpack.BufferObj->RefCount--; - if (ctx->Unpack.BufferObj->RefCount <= 0) { - _mesa_remove_buffer_object( ctx, ctx->Unpack.BufferObj ); - (*ctx->Driver.DeleteBuffer)( ctx, ctx->Unpack.BufferObj ); + { + struct gl_pixelstore_attrib *store = + (struct gl_pixelstore_attrib *) node->data; + copy_pixelstore(ctx, &ctx->Unpack, store); + _mesa_reference_buffer_object(ctx, &store->BufferObj, NULL); } -#endif - MEMCPY( &ctx->Unpack, attr->data, - sizeof(struct gl_pixelstore_attrib) ); ctx->NewState |= _NEW_PACKUNPACK; break; case GL_CLIENT_VERTEX_ARRAY_BIT: { struct gl_array_attrib * data = - (struct gl_array_attrib *) attr->data; + (struct gl_array_attrib *) node->data; adjust_buffer_object_ref_counts(&ctx->Array, -1); @@ -1431,10 +1446,10 @@ _mesa_PopClientAttrib(void) break; } - next = attr->next; - FREE( attr->data ); - FREE( attr ); - attr = next; + next = node->next; + FREE( node->data ); + FREE( node ); + node = next; } } diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c index eb418610a7..1b58f5e96a 100644 --- a/src/mesa/main/bufferobj.c +++ b/src/mesa/main/bufferobj.c @@ -1,6 +1,6 @@ /* * Mesa 3-D graphics library - * Version: 7.1 + * Version: 7.2 * * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. * @@ -166,22 +166,75 @@ _mesa_delete_buffer_object( GLcontext *ctx, struct gl_buffer_object *bufObj ) if (bufObj->Data) _mesa_free(bufObj->Data); + + /* assign strange values here to help w/ debugging */ + bufObj->RefCount = -1000; + bufObj->Name = ~0; + _mesa_free(bufObj); } + +/** + * Set ptr to bufObj w/ reference counting. + */ void -_mesa_unbind_buffer_object( GLcontext *ctx, struct gl_buffer_object *bufObj ) +_mesa_reference_buffer_object(GLcontext *ctx, + struct gl_buffer_object **ptr, + struct gl_buffer_object *bufObj) { - if (bufObj != ctx->Array.NullBufferObj) { - bufObj->RefCount--; - if (bufObj->RefCount <= 0) { + if (*ptr == bufObj) + return; + + if (*ptr) { + /* Unreference the old texture */ + GLboolean deleteFlag = GL_FALSE; + struct gl_buffer_object *oldObj = *ptr; + + /*_glthread_LOCK_MUTEX(oldObj->Mutex);*/ + ASSERT(oldObj->RefCount > 0); + oldObj->RefCount--; +#if 0 + printf("BufferObj %p %d DECR to %d\n", + (void *) oldObj, oldObj->Name, oldObj->RefCount); +#endif + deleteFlag = (oldObj->RefCount == 0); + /*_glthread_UNLOCK_MUTEX(oldObj->Mutex);*/ + + if (deleteFlag) { + + /* some sanity checking: don't delete a buffer still in use */ ASSERT(ctx->Array.ArrayBufferObj != bufObj); ASSERT(ctx->Array.ElementArrayBufferObj != bufObj); ASSERT(ctx->Array.ArrayObj->Vertex.BufferObj != bufObj); ASSERT(ctx->Driver.DeleteBuffer); - ctx->Driver.DeleteBuffer(ctx, bufObj); + + ctx->Driver.DeleteBuffer(ctx, oldObj); } + + *ptr = NULL; + } + ASSERT(!*ptr); + + if (bufObj) { + /* reference new texture */ + /*_glthread_LOCK_MUTEX(tex->Mutex);*/ + if (bufObj->RefCount == 0) { + /* this buffer's being deleted (look just above) */ + /* Not sure this can every really happen. Warn if it does. */ + _mesa_problem(NULL, "referencing deleted buffer object"); + *ptr = NULL; + } + else { + bufObj->RefCount++; +#if 0 + printf("BufferObj %p %d INCR to %d\n", + (void *) bufObj, bufObj->Name, bufObj->RefCount); +#endif + *ptr = bufObj; + } + /*_glthread_UNLOCK_MUTEX(tex->Mutex);*/ } } @@ -203,33 +256,6 @@ _mesa_initialize_buffer_object( struct gl_buffer_object *obj, } -/** - * Add the given buffer object to the buffer object pool. - */ -void -_mesa_save_buffer_object( GLcontext *ctx, struct gl_buffer_object *obj ) -{ - if (obj->Name > 0) { - /* insert into hash table */ - _mesa_HashInsert(ctx->Shared->BufferObjects, obj->Name, obj); - } -} - - -/** - * Remove the given buffer object from the buffer object pool. - * Do not deallocate the buffer object though. - */ -void -_mesa_remove_buffer_object( GLcontext *ctx, struct gl_buffer_object *bufObj ) -{ - if (bufObj->Name > 0) { - /* remove from hash table */ - _mesa_HashRemove(ctx->Shared->BufferObjects, bufObj->Name); - } -} - - /** * Allocate space for and store data in a buffer object. Any data that was * previously stored in the buffer object is lost. If \c data is \c NULL, @@ -400,6 +426,7 @@ _mesa_init_buffer_objects( GLcontext *ctx ) { /* Allocate the default buffer object and set refcount so high that * it never gets deleted. + * XXX with recent/improved refcounting this may not longer be needed. */ ctx->Array.NullBufferObj = _mesa_new_buffer_object(ctx, 0, 0); if (ctx->Array.NullBufferObj) @@ -462,28 +489,16 @@ bind_buffer_object(GLcontext *ctx, GLenum target, GLuint buffer) _mesa_error(ctx, GL_OUT_OF_MEMORY, "glBindBufferARB"); return; } - _mesa_save_buffer_object(ctx, newBufObj); + _mesa_HashInsert(ctx->Shared->BufferObjects, buffer, newBufObj); } } - /* Make new binding */ - *bindTarget = newBufObj; - newBufObj->RefCount++; + /* bind new buffer */ + _mesa_reference_buffer_object(ctx, bindTarget, newBufObj); /* Pass BindBuffer call to device driver */ if (ctx->Driver.BindBuffer && newBufObj) ctx->Driver.BindBuffer( ctx, target, newBufObj ); - - /* decr ref count on old buffer obj, delete if needed */ - if (oldBufObj) { - oldBufObj->RefCount--; - assert(oldBufObj->RefCount >= 0); - if (oldBufObj->RefCount == 0) { - assert(oldBufObj->Name != 0); - ASSERT(ctx->Driver.DeleteBuffer); - ctx->Driver.DeleteBuffer( ctx, oldBufObj ); - } - } } @@ -716,6 +731,23 @@ _mesa_lookup_bufferobj(GLcontext *ctx, GLuint buffer) } +/** + * If *ptr points to obj, set ptr = the Null/default buffer object. + * This is a helper for buffer object deletion. + * The GL spec says that deleting a buffer object causes it to get + * unbound from all arrays in the current context. + */ +static void +unbind(GLcontext *ctx, + struct gl_buffer_object **ptr, + struct gl_buffer_object *obj) +{ + if (*ptr == obj) { + _mesa_reference_buffer_object(ctx, ptr, ctx->Array.NullBufferObj); + } +} + + /**********************************************************************/ /* API Functions */ @@ -759,54 +791,18 @@ _mesa_DeleteBuffersARB(GLsizei n, const GLuint *ids) ASSERT(bufObj->Name == ids[i]); - if (ctx->Array.ArrayObj->Vertex.BufferObj == bufObj) { - bufObj->RefCount--; - ctx->Array.ArrayObj->Vertex.BufferObj = ctx->Array.NullBufferObj; - ctx->Array.NullBufferObj->RefCount++; - } - if (ctx->Array.ArrayObj->Normal.BufferObj == bufObj) { - bufObj->RefCount--; - ctx->Array.ArrayObj->Normal.BufferObj = ctx->Array.NullBufferObj; - ctx->Array.NullBufferObj->RefCount++; - } - if (ctx->Array.ArrayObj->Color.BufferObj == bufObj) { - bufObj->RefCount--; - ctx->Array.ArrayObj->Color.BufferObj = ctx->Array.NullBufferObj; - ctx->Array.NullBufferObj->RefCount++; - } - if (ctx->Array.ArrayObj->SecondaryColor.BufferObj == bufObj) { - bufObj->RefCount--; - ctx->Array.ArrayObj->SecondaryColor.BufferObj = ctx->Array.NullBufferObj; - ctx->Array.NullBufferObj->RefCount++; - } - if (ctx->Array.ArrayObj->FogCoord.BufferObj == bufObj) { - bufObj->RefCount--; - ctx->Array.ArrayObj->FogCoord.BufferObj = ctx->Array.NullBufferObj; - ctx->Array.NullBufferObj->RefCount++; - } - if (ctx->Array.ArrayObj->Index.BufferObj == bufObj) { - bufObj->RefCount--; - ctx->Array.ArrayObj->Index.BufferObj = ctx->Array.NullBufferObj; - ctx->Array.NullBufferObj->RefCount++; - } - if (ctx->Array.ArrayObj->EdgeFlag.BufferObj == bufObj) { - bufObj->RefCount--; - ctx->Array.ArrayObj->EdgeFlag.BufferObj = ctx->Array.NullBufferObj; - ctx->Array.NullBufferObj->RefCount++; - } + unbind(ctx, &ctx->Array.ArrayObj->Vertex.BufferObj, bufObj); + unbind(ctx, &ctx->Array.ArrayObj->Normal.BufferObj, bufObj); + unbind(ctx, &ctx->Array.ArrayObj->Color.BufferObj, bufObj); + unbind(ctx, &ctx->Array.ArrayObj->SecondaryColor.BufferObj, bufObj); + unbind(ctx, &ctx->Array.ArrayObj->FogCoord.BufferObj, bufObj); + unbind(ctx, &ctx->Array.ArrayObj->Index.BufferObj, bufObj); + unbind(ctx, &ctx->Array.ArrayObj->EdgeFlag.BufferObj, bufObj); for (j = 0; j < MAX_TEXTURE_UNITS; j++) { - if (ctx->Array.ArrayObj->TexCoord[j].BufferObj == bufObj) { - bufObj->RefCount--; - ctx->Array.ArrayObj->TexCoord[j].BufferObj = ctx->Array.NullBufferObj; - ctx->Array.NullBufferObj->RefCount++; - } + unbind(ctx, &ctx->Array.ArrayObj->TexCoord[j].BufferObj, bufObj); } for (j = 0; j < VERT_ATTRIB_MAX; j++) { - if (ctx->Array.ArrayObj->VertexAttrib[j].BufferObj == bufObj) { - bufObj->RefCount--; - ctx->Array.ArrayObj->VertexAttrib[j].BufferObj = ctx->Array.NullBufferObj; - ctx->Array.NullBufferObj->RefCount++; - } + unbind(ctx, &ctx->Array.ArrayObj->VertexAttrib[j].BufferObj, bufObj); } if (ctx->Array.ArrayBufferObj == bufObj) { @@ -824,8 +820,8 @@ _mesa_DeleteBuffersARB(GLsizei n, const GLuint *ids) } /* The ID is immediately freed for re-use */ - _mesa_remove_buffer_object(ctx, bufObj); - _mesa_unbind_buffer_object(ctx, bufObj); + _mesa_HashRemove(ctx->Shared->BufferObjects, bufObj->Name); + _mesa_reference_buffer_object(ctx, &bufObj, NULL); } } @@ -874,7 +870,7 @@ _mesa_GenBuffersARB(GLsizei n, GLuint *buffer) _mesa_error(ctx, GL_OUT_OF_MEMORY, "glGenBuffersARB"); return; } - _mesa_save_buffer_object(ctx, bufObj); + _mesa_HashInsert(ctx->Shared->BufferObjects, first + i, bufObj); buffer[i] = first + i; } diff --git a/src/mesa/main/bufferobj.h b/src/mesa/main/bufferobj.h index 8baa59d617..163fe241aa 100644 --- a/src/mesa/main/bufferobj.h +++ b/src/mesa/main/bufferobj.h @@ -1,6 +1,6 @@ /* * Mesa 3-D graphics library - * Version: 7.1 + * Version: 7.2 * * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. * @@ -55,10 +55,9 @@ _mesa_initialize_buffer_object( struct gl_buffer_object *obj, GLuint name, GLenum target ); extern void -_mesa_save_buffer_object( GLcontext *ctx, struct gl_buffer_object *obj ); - -extern void -_mesa_remove_buffer_object( GLcontext *ctx, struct gl_buffer_object *bufObj ); +_mesa_reference_buffer_object(GLcontext *ctx, + struct gl_buffer_object **ptr, + struct gl_buffer_object *bufObj); extern void _mesa_buffer_data( GLcontext *ctx, GLenum target, GLsizeiptrARB size, @@ -118,8 +117,6 @@ _mesa_unmap_readpix_pbo(GLcontext *ctx, const struct gl_pixelstore_attrib *pack); -extern void -_mesa_unbind_buffer_object( GLcontext *ctx, struct gl_buffer_object *bufObj ); /* * API functions diff --git a/src/mesa/main/varray.c b/src/mesa/main/varray.c index 22a55ac707..67dd093f2a 100644 --- a/src/mesa/main/varray.c +++ b/src/mesa/main/varray.c @@ -1,8 +1,8 @@ /* * Mesa 3-D graphics library - * Version: 6.5.1 + * Version: 7.2 * - * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -62,14 +62,9 @@ update_array(GLcontext *ctx, struct gl_client_array *array, array->Normalized = normalized; array->Ptr = (const GLubyte *) ptr; #if FEATURE_ARB_vertex_buffer_object - array->BufferObj->RefCount--; - if (array->BufferObj->RefCount <= 0) { - ASSERT(array->BufferObj->Name); - _mesa_remove_buffer_object( ctx, array->BufferObj ); - (*ctx->Driver.DeleteBuffer)( ctx, array->BufferObj ); - } - array->BufferObj = ctx->Array.ArrayBufferObj; - array->BufferObj->RefCount++; + _mesa_reference_buffer_object(ctx, &array->BufferObj, + ctx->Array.ArrayBufferObj); + /* Compute the index of the last array element that's inside the buffer. * Later in glDrawArrays we'll check if start + count > _MaxElement to * be sure we won't go out of bounds. diff --git a/src/mesa/vbo/vbo_exec_api.c b/src/mesa/vbo/vbo_exec_api.c index d07d5ba80a..45971a4735 100644 --- a/src/mesa/vbo/vbo_exec_api.c +++ b/src/mesa/vbo/vbo_exec_api.c @@ -1,6 +1,6 @@ /************************************************************************** -Copyright 2002 Tungsten Graphics Inc., Cedar Park, Texas. +Copyright 2002-2008 Tungsten Graphics Inc., Cedar Park, Texas. All Rights Reserved. @@ -31,6 +31,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include "main/glheader.h" +#include "main/bufferobj.h" #include "main/context.h" #include "main/macros.h" #include "main/vtxfmt.h" @@ -655,7 +656,10 @@ void vbo_exec_vtx_init( struct vbo_exec_context *exec ) /* Allocate a buffer object. Will just reuse this object * continuously. */ - exec->vtx.bufferobj = ctx->Array.NullBufferObj; + _mesa_reference_buffer_object(ctx, + &exec->vtx.bufferobj, + ctx->Array.NullBufferObj); + exec->vtx.buffer_map = ALIGN_MALLOC(VBO_VERT_BUFFER_SIZE * sizeof(GLfloat), 64); vbo_exec_vtxfmt_init( exec ); diff --git a/src/mesa/vbo/vbo_exec_draw.c b/src/mesa/vbo/vbo_exec_draw.c index 68ce7ba837..5f737fd90f 100644 --- a/src/mesa/vbo/vbo_exec_draw.c +++ b/src/mesa/vbo/vbo_exec_draw.c @@ -1,8 +1,8 @@ /* * Mesa 3-D graphics library - * Version: 5.1 + * Version: 7.2 * - * Copyright (C) 1999-2003 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -26,6 +26,7 @@ */ #include "main/glheader.h" +#include "main/bufferobj.h" #include "main/context.h" #include "main/enums.h" #include "main/state.h" @@ -155,8 +156,12 @@ static void vbo_exec_bind_arrays( GLcontext *ctx ) */ switch (get_program_mode(exec->ctx)) { case VP_NONE: - memcpy(arrays, vbo->legacy_currval, 16 * sizeof(arrays[0])); - memcpy(arrays + 16, vbo->mat_currval, MAT_ATTRIB_MAX * sizeof(arrays[0])); + for (attr = 0; attr < 16; attr++) { + exec->vtx.inputs[attr] = &vbo->legacy_currval[attr]; + } + for (attr = 0; attr < MAT_ATTRIB_MAX; attr++) { + exec->vtx.inputs[attr + 16] = &vbo->mat_currval[attr]; + } map = vbo->map_vp_none; break; case VP_NV: @@ -165,8 +170,10 @@ static void vbo_exec_bind_arrays( GLcontext *ctx ) * occurred. NV vertex programs cannot access material values, * nor attributes greater than VERT_ATTRIB_TEX7. */ - memcpy(arrays, vbo->legacy_currval, 16 * sizeof(arrays[0])); - memcpy(arrays + 16, vbo->generic_currval, 16 * sizeof(arrays[0])); + for (attr = 0; attr < 16; attr++) { + exec->vtx.inputs[attr] = &vbo->legacy_currval[attr]; + exec->vtx.inputs[attr + 16] = &vbo->generic_currval[attr]; + } map = vbo->map_vp_arb; break; } @@ -178,13 +185,18 @@ static void vbo_exec_bind_arrays( GLcontext *ctx ) GLuint src = map[attr]; if (exec->vtx.attrsz[src]) { + /* override the default array set above */ + exec->vtx.inputs[attr] = &arrays[attr]; + arrays[attr].Ptr = (void *)data; arrays[attr].Size = exec->vtx.attrsz[src]; arrays[attr].StrideB = exec->vtx.vertex_size * sizeof(GLfloat); arrays[attr].Stride = exec->vtx.vertex_size * sizeof(GLfloat); arrays[attr].Type = GL_FLOAT; arrays[attr].Enabled = 1; - arrays[attr].BufferObj = exec->vtx.bufferobj; /* NullBufferObj */ + _mesa_reference_buffer_object(ctx, + &arrays[attr].BufferObj, + exec->vtx.bufferobj); arrays[attr]._MaxElement = count; /* ??? */ data += exec->vtx.attrsz[src] * sizeof(GLfloat); diff --git a/src/mesa/vbo/vbo_save.c b/src/mesa/vbo/vbo_save.c index 8dd87141c0..9757c3d9f6 100644 --- a/src/mesa/vbo/vbo_save.c +++ b/src/mesa/vbo/vbo_save.c @@ -1,8 +1,8 @@ /* * Mesa 3-D graphics library - * Version: 6.3 + * Version: 7.2 * - * Copyright (C) 1999-2005 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -27,6 +27,7 @@ #include "main/mtypes.h" +#include "main/bufferobj.h" #include "main/dlist.h" #include "main/vtxfmt.h" #include "main/imports.h" @@ -71,19 +72,24 @@ void vbo_save_destroy( GLcontext *ctx ) { struct vbo_context *vbo = vbo_context(ctx); struct vbo_save_context *save = &vbo->save; + GLuint i; + if (save->prim_store) { if ( --save->prim_store->refcount == 0 ) { FREE( save->prim_store ); save->prim_store = NULL; } if ( --save->vertex_store->refcount == 0 ) { - if (save->vertex_store->bufferobj) - ctx->Driver.DeleteBuffer( ctx, save->vertex_store->bufferobj ); - + _mesa_reference_buffer_object(ctx, + &save->vertex_store->bufferobj, NULL); FREE( save->vertex_store ); save->vertex_store = NULL; } } + + for (i = 0; i < VBO_ATTRIB_MAX; i++) { + _mesa_reference_buffer_object(ctx, &save->arrays[i].BufferObj, NULL); + } } diff --git a/src/mesa/vbo/vbo_save_api.c b/src/mesa/vbo/vbo_save_api.c index f62be5c14c..88d573f128 100644 --- a/src/mesa/vbo/vbo_save_api.c +++ b/src/mesa/vbo/vbo_save_api.c @@ -1,6 +1,6 @@ /************************************************************************** -Copyright 2002 Tungsten Graphics Inc., Cedar Park, Texas. +Copyright 2002-2008 Tungsten Graphics Inc., Cedar Park, Texas. All Rights Reserved. @@ -68,6 +68,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. #include "main/glheader.h" +#include "main/bufferobj.h" #include "main/context.h" #include "main/dlist.h" #include "main/enums.h" @@ -85,6 +86,10 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. #endif +/* An interesting VBO number/name to help with debugging */ +#define VBO_BUF_ID 12345 + + /* * NOTE: Old 'parity' issue is gone, but copying can still be * wrong-footed on replay. @@ -170,7 +175,9 @@ static struct vbo_save_vertex_store *alloc_vertex_store( GLcontext *ctx ) * user. Perhaps there could be a special number for internal * buffers: */ - vertex_store->bufferobj = ctx->Driver.NewBufferObject(ctx, 1, GL_ARRAY_BUFFER_ARB); + vertex_store->bufferobj = ctx->Driver.NewBufferObject(ctx, + VBO_BUF_ID, + GL_ARRAY_BUFFER_ARB); ctx->Driver.BufferData( ctx, GL_ARRAY_BUFFER_ARB, @@ -190,8 +197,9 @@ static void free_vertex_store( GLcontext *ctx, struct vbo_save_vertex_store *ver { assert(!vertex_store->buffer); - if (vertex_store->bufferobj) - ctx->Driver.DeleteBuffer( ctx, vertex_store->bufferobj ); + if (vertex_store->bufferobj) { + _mesa_reference_buffer_object(ctx, &vertex_store->bufferobj, NULL); + } FREE( vertex_store ); } @@ -1139,6 +1147,7 @@ void vbo_save_api_init( struct vbo_save_context *save ) _save_vtxfmt_init( ctx ); _save_current_init( ctx ); + /* These will actually get set again when binding/drawing */ for (i = 0; i < VBO_ATTRIB_MAX; i++) save->inputs[i] = &save->arrays[i]; diff --git a/src/mesa/vbo/vbo_save_draw.c b/src/mesa/vbo/vbo_save_draw.c index bf5c6d4eef..ed82f09958 100644 --- a/src/mesa/vbo/vbo_save_draw.c +++ b/src/mesa/vbo/vbo_save_draw.c @@ -1,8 +1,8 @@ /* * Mesa 3-D graphics library - * Version: 6.1 + * Version: 7.2 * - * Copyright (C) 1999-2004 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -27,6 +27,7 @@ */ #include "main/glheader.h" +#include "main/bufferobj.h" #include "main/context.h" #include "main/imports.h" #include "main/mtypes.h" @@ -115,8 +116,12 @@ static void vbo_bind_vertex_list( GLcontext *ctx, */ switch (get_program_mode(ctx)) { case VP_NONE: - memcpy(arrays, vbo->legacy_currval, 16 * sizeof(arrays[0])); - memcpy(arrays + 16, vbo->mat_currval, MAT_ATTRIB_MAX * sizeof(arrays[0])); + for (attr = 0; attr < 16; attr++) { + save->inputs[attr] = &vbo->legacy_currval[attr]; + } + for (attr = 0; attr < MAT_ATTRIB_MAX; attr++) { + save->inputs[attr + 16] = &vbo->mat_currval[attr]; + } map = vbo->map_vp_none; break; case VP_NV: @@ -125,8 +130,10 @@ static void vbo_bind_vertex_list( GLcontext *ctx, * occurred. NV vertex programs cannot access material values, * nor attributes greater than VERT_ATTRIB_TEX7. */ - memcpy(arrays, vbo->legacy_currval, 16 * sizeof(arrays[0])); - memcpy(arrays + 16, vbo->generic_currval, 16 * sizeof(arrays[0])); + for (attr = 0; attr < 16; attr++) { + save->inputs[attr] = &vbo->legacy_currval[attr]; + save->inputs[attr + 16] = &vbo->generic_currval[attr]; + } map = vbo->map_vp_arb; break; } @@ -135,13 +142,18 @@ static void vbo_bind_vertex_list( GLcontext *ctx, GLuint src = map[attr]; if (node->attrsz[src]) { - arrays[attr].Ptr = (const GLubyte *)data; + /* override the default array set above */ + save->inputs[attr] = &arrays[attr]; + + arrays[attr].Ptr = (const GLubyte *) data; arrays[attr].Size = node->attrsz[src]; arrays[attr].StrideB = node->vertex_size * sizeof(GLfloat); arrays[attr].Stride = node->vertex_size * sizeof(GLfloat); arrays[attr].Type = GL_FLOAT; arrays[attr].Enabled = 1; - arrays[attr].BufferObj = node->vertex_store->bufferobj; + _mesa_reference_buffer_object(ctx, + &arrays[attr].BufferObj, + node->vertex_store->bufferobj); arrays[attr]._MaxElement = node->count; /* ??? */ assert(arrays[attr].BufferObj->Name); -- cgit v1.2.3 From 06537296f18750a9442e3007fe7d8b2b966dd2cc Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Fri, 5 Sep 2008 13:48:51 +1000 Subject: intel: only enable occlusion query if the drm has defines. This interface has to be re-written to not be dumb and to work for multiple apps. --- src/mesa/drivers/dri/intel/intel_context.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src') diff --git a/src/mesa/drivers/dri/intel/intel_context.c b/src/mesa/drivers/dri/intel/intel_context.c index c2ad5a0423..18e73484ae 100644 --- a/src/mesa/drivers/dri/intel/intel_context.c +++ b/src/mesa/drivers/dri/intel/intel_context.c @@ -409,10 +409,12 @@ static const struct dri_extension brw_extensions[] = { { NULL, NULL } }; +#ifdef I915_MMIO_READ static const struct dri_extension arb_oc_extensions[] = { {"GL_ARB_occlusion_query", GL_ARB_occlusion_query_functions}, {NULL, NULL} }; +#endif static const struct dri_extension ttm_extensions[] = { {"GL_EXT_framebuffer_object", GL_EXT_framebuffer_object_functions}, @@ -437,10 +439,12 @@ void intelInitExtensions(GLcontext *ctx, GLboolean enable_imaging) if (intel == NULL || intel->ttm) driInitExtensions(ctx, ttm_extensions, GL_FALSE); +#ifdef I915_MMIO_READ if (intel == NULL || (IS_965(intel->intelScreen->deviceID) && intel->intelScreen->drmMinor >= 8)) driInitExtensions(ctx, arb_oc_extensions, GL_FALSE); +#endif if (intel == NULL || IS_965(intel->intelScreen->deviceID)) driInitExtensions(ctx, brw_extensions, GL_FALSE); @@ -538,6 +542,7 @@ intelFinish(GLcontext * ctx) } } +#ifdef I915_MMIO_READ static void intelBeginQuery(GLcontext *ctx, GLenum target, struct gl_query_object *q) { @@ -568,6 +573,7 @@ intelEndQuery(GLcontext *ctx, GLenum target, struct gl_query_object *q) q->Ready = GL_TRUE; intel->stats_wm--; } +#endif /** Driver-specific fence emit implementation for the fake memory manager. */ static unsigned int @@ -684,8 +690,10 @@ intelInitDriverFunctions(struct dd_function_table *functions) functions->CopyConvolutionFilter1D = _swrast_CopyConvolutionFilter1D; functions->CopyConvolutionFilter2D = _swrast_CopyConvolutionFilter2D; +#ifdef I915_MMIO_READ functions->BeginQuery = intelBeginQuery; functions->EndQuery = intelEndQuery; +#endif intelInitTextureFuncs(functions); intelInitStateFuncs(functions); -- cgit v1.2.3 From 9246c2fad437f3922abb20ed86156963a488be3d Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 4 Sep 2008 15:25:32 -0600 Subject: mesa: replace MALLOC w/ CALLOC to fix valgrind warning --- src/mesa/main/arrayobj.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/mesa/main/arrayobj.c b/src/mesa/main/arrayobj.c index 0bc582602e..b50e9d1d56 100644 --- a/src/mesa/main/arrayobj.c +++ b/src/mesa/main/arrayobj.c @@ -77,7 +77,7 @@ lookup_arrayobj(GLcontext *ctx, GLuint id) struct gl_array_object * _mesa_new_array_object( GLcontext *ctx, GLuint name ) { - struct gl_array_object *obj = MALLOC_STRUCT(gl_array_object); + struct gl_array_object *obj = CALLOC_STRUCT(gl_array_object); if (obj) _mesa_initialize_array_object(ctx, obj, name); return obj; -- cgit v1.2.3 From 11d694b1bb0cb384d802d7e0e252cf5119febb98 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 5 Sep 2008 08:06:59 -0600 Subject: mesa: replace MALLOC w/ CALLOC to fix memory error in glPushClientAttrib() --- src/mesa/main/attrib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/mesa/main/attrib.c b/src/mesa/main/attrib.c index 94475b981d..59babeb47b 100644 --- a/src/mesa/main/attrib.c +++ b/src/mesa/main/attrib.c @@ -1330,7 +1330,7 @@ _mesa_PushClientAttrib(GLbitfield mask) newnode->next = head; head = newnode; /* unpacking attribs */ - attr = MALLOC_STRUCT( gl_pixelstore_attrib ); + attr = CALLOC_STRUCT( gl_pixelstore_attrib ); copy_pixelstore(ctx, attr, &ctx->Unpack); newnode = new_attrib_node( GL_CLIENT_UNPACK_BIT ); newnode->data = attr; -- cgit v1.2.3 From 7e0bbdcf033981282978554c2e68ce48b55aa291 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 4 Sep 2008 22:16:31 +0100 Subject: intel: Move the bufmgr back to the screen. Mesa requires that we be able to share objects between contexts, which means that the objects need to be created by the same bufmgr, and the bufmgr internally requires pthread protection for thread safety. Rely on the bufmgr having appropriate locking. --- src/mesa/drivers/dri/intel/intel_batchbuffer.c | 4 +- src/mesa/drivers/dri/intel/intel_context.c | 115 +++---------------------- src/mesa/drivers/dri/intel/intel_ioctl.c | 21 +++-- src/mesa/drivers/dri/intel/intel_ioctl.h | 4 +- src/mesa/drivers/dri/intel/intel_screen.c | 98 +++++++++++++++++++++ src/mesa/drivers/dri/intel/intel_screen.h | 4 + 6 files changed, 132 insertions(+), 114 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/intel/intel_batchbuffer.c b/src/mesa/drivers/dri/intel/intel_batchbuffer.c index 5afaad070c..550f467f83 100644 --- a/src/mesa/drivers/dri/intel/intel_batchbuffer.c +++ b/src/mesa/drivers/dri/intel/intel_batchbuffer.c @@ -265,9 +265,9 @@ _intel_batchbuffer_flush(struct intel_batchbuffer *batch, const char *file, fprintf(stderr, "waiting for idle\n"); LOCK_HARDWARE(intel); - irq = intelEmitIrqLocked(intel); + irq = intelEmitIrqLocked(intel->intelScreen); UNLOCK_HARDWARE(intel); - intelWaitIrq(intel, irq); + intelWaitIrq(intel->intelScreen, irq); } /* Reset the buffer: diff --git a/src/mesa/drivers/dri/intel/intel_context.c b/src/mesa/drivers/dri/intel/intel_context.c index 18e73484ae..15ab9cbf35 100644 --- a/src/mesa/drivers/dri/intel/intel_context.c +++ b/src/mesa/drivers/dri/intel/intel_context.c @@ -575,105 +575,6 @@ intelEndQuery(GLcontext *ctx, GLenum target, struct gl_query_object *q) } #endif -/** Driver-specific fence emit implementation for the fake memory manager. */ -static unsigned int -intel_fence_emit(void *private) -{ - struct intel_context *intel = (struct intel_context *)private; - unsigned int fence; - - /* XXX: Need to emit a flush, if we haven't already (at least with the - * current batchbuffer implementation, we have). - */ - - fence = intelEmitIrqLocked(intel); - - return fence; -} - -/** Driver-specific fence wait implementation for the fake memory manager. */ -static int -intel_fence_wait(void *private, unsigned int cookie) -{ - struct intel_context *intel = (struct intel_context *)private; - - intelWaitIrq(intel, cookie); - - return 0; -} - -static GLboolean -intel_init_bufmgr(struct intel_context *intel) -{ - intelScreenPrivate *intelScreen = intel->intelScreen; - GLboolean gem_disable = getenv("INTEL_NO_GEM") != NULL; - int gem_kernel = 0; - GLboolean gem_supported; - struct drm_i915_getparam gp; - - gp.param = I915_PARAM_HAS_GEM; - gp.value = &gem_kernel; - - (void) drmCommandWriteRead(intel->driFd, DRM_I915_GETPARAM, &gp, sizeof(gp)); - - /* If we've got a new enough DDX that's initializing GEM and giving us - * object handles for the shared buffers, use that. - */ - intel->ttm = GL_FALSE; - if (intel->intelScreen->driScrnPriv->dri2.enabled) - gem_supported = GL_TRUE; - else if (intel->intelScreen->driScrnPriv->ddx_version.minor >= 9 && - gem_kernel && - intel->intelScreen->front.bo_handle != -1) - gem_supported = GL_TRUE; - else - gem_supported = GL_FALSE; - - if (!gem_disable && gem_supported) { - int bo_reuse_mode; - intel->bufmgr = intel_bufmgr_gem_init(intel->driFd, - BATCH_SZ); - if (intel->bufmgr != NULL) - intel->ttm = GL_TRUE; - - bo_reuse_mode = driQueryOptioni(&intel->optionCache, "bo_reuse"); - switch (bo_reuse_mode) { - case DRI_CONF_BO_REUSE_DISABLED: - break; - case DRI_CONF_BO_REUSE_ALL: - intel_bufmgr_gem_enable_reuse(intel->bufmgr); - break; - } - } - /* Otherwise, use the classic buffer manager. */ - if (intel->bufmgr == NULL) { - if (gem_disable) { - fprintf(stderr, "GEM disabled. Using classic.\n"); - } else { - fprintf(stderr, "Failed to initialize GEM. " - "Falling back to classic.\n"); - } - - if (intelScreen->tex.size == 0) { - fprintf(stderr, "[%s:%u] Error initializing buffer manager.\n", - __func__, __LINE__); - return GL_FALSE; - } - - intel->bufmgr = intel_bufmgr_fake_init(intelScreen->tex.offset, - intelScreen->tex.map, - intelScreen->tex.size, - intel_fence_emit, - intel_fence_wait, - intel); - } - - /* XXX bufmgr should be per-screen, not per-context */ - intelScreen->ttm = intel->ttm; - - return GL_TRUE; -} - void intelInitDriverFunctions(struct dd_function_table *functions) { @@ -745,8 +646,20 @@ intelInitContext(struct intel_context *intel, else intel->maxBatchSize = BATCH_SZ; - if (!intel_init_bufmgr(intel)) - return GL_FALSE; + intel->bufmgr = intelScreen->bufmgr; + intel->ttm = intelScreen->ttm; + if (intel->ttm) { + int bo_reuse_mode; + + bo_reuse_mode = driQueryOptioni(&intel->optionCache, "bo_reuse"); + switch (bo_reuse_mode) { + case DRI_CONF_BO_REUSE_DISABLED: + break; + case DRI_CONF_BO_REUSE_ALL: + intel_bufmgr_gem_enable_reuse(intel->bufmgr); + break; + } + } ctx->Const.MaxTextureMaxAnisotropy = 2.0; diff --git a/src/mesa/drivers/dri/intel/intel_ioctl.c b/src/mesa/drivers/dri/intel/intel_ioctl.c index 58c81766cd..ac9e9337d6 100644 --- a/src/mesa/drivers/dri/intel/intel_ioctl.c +++ b/src/mesa/drivers/dri/intel/intel_ioctl.c @@ -50,22 +50,23 @@ #define FILE_DEBUG_FLAG DEBUG_IOCTL int -intelEmitIrqLocked(struct intel_context *intel) +intelEmitIrqLocked(intelScreenPrivate *intelScreen) { + __DRIscreenPrivate *spriv = intelScreen->driScrnPriv; struct drm_i915_irq_emit ie; int ret, seq = 1; - if (intel->no_hw) + if (intelScreen->no_hw) return 1; /* - assert(((*(int *)intel->driHwLock) & ~DRM_LOCK_CONT) == - (DRM_LOCK_HELD|intel->hHWContext)); + assert(((*(int *)intelScreen->driHwLock) & ~DRM_LOCK_CONT) == + (DRM_LOCK_HELD|intelScreen->hHWContext)); */ ie.irq_seq = &seq; - ret = drmCommandWriteRead(intel->driFd, DRM_I915_IRQ_EMIT, &ie, sizeof(ie)); + ret = drmCommandWriteRead(spriv->fd, DRM_I915_IRQ_EMIT, &ie, sizeof(ie)); if (ret) { fprintf(stderr, "%s: drm_i915_irq_emit: %d\n", __FUNCTION__, ret); exit(1); @@ -77,13 +78,15 @@ intelEmitIrqLocked(struct intel_context *intel) } void -intelWaitIrq(struct intel_context *intel, int seq) +intelWaitIrq(intelScreenPrivate *intelScreen, int seq) { + __DRIscreenPrivate *spriv = intelScreen->driScrnPriv; struct drm_i915_irq_wait iw; int ret, lastdispatch; - volatile struct drm_i915_sarea *sarea = intel->sarea; + volatile struct drm_i915_sarea *sarea = (struct drm_i915_sarea *) + (((GLubyte *) spriv->pSAREA) + intelScreen->sarea_priv_offset); - if (intel->no_hw) + if (intelScreen->no_hw) return; DBG("%s %d\n", __FUNCTION__, seq); @@ -92,7 +95,7 @@ intelWaitIrq(struct intel_context *intel, int seq) do { lastdispatch = sarea->last_dispatch; - ret = drmCommandWrite(intel->driFd, DRM_I915_IRQ_WAIT, &iw, sizeof(iw)); + ret = drmCommandWrite(spriv->fd, DRM_I915_IRQ_WAIT, &iw, sizeof(iw)); } while (ret == -EAGAIN || ret == -EINTR || (ret == -EBUSY && lastdispatch != sarea->last_dispatch) || diff --git a/src/mesa/drivers/dri/intel/intel_ioctl.h b/src/mesa/drivers/dri/intel/intel_ioctl.h index 526e38358c..2ea40001db 100644 --- a/src/mesa/drivers/dri/intel/intel_ioctl.h +++ b/src/mesa/drivers/dri/intel/intel_ioctl.h @@ -30,8 +30,8 @@ #include "intel_context.h" -void intelWaitIrq( struct intel_context *intel, int seq ); -int intelEmitIrqLocked( struct intel_context *intel ); +void intelWaitIrq(intelScreenPrivate *intelScreen, int seq); +int intelEmitIrqLocked(intelScreenPrivate *intelScreen); int intel_batch_ioctl(struct intel_context *intel, GLuint start_offset, diff --git a/src/mesa/drivers/dri/intel/intel_screen.c b/src/mesa/drivers/dri/intel/intel_screen.c index c193830f05..5cfb893305 100644 --- a/src/mesa/drivers/dri/intel/intel_screen.c +++ b/src/mesa/drivers/dri/intel/intel_screen.c @@ -552,6 +552,96 @@ intelFillInModes(__DRIscreenPrivate *psp, } +/** Driver-specific fence emit implementation for the fake memory manager. */ +static unsigned int +intel_fence_emit(void *private) +{ + intelScreenPrivate *intelScreen = (intelScreenPrivate *)private; + unsigned int fence; + + /* XXX: Need to emit a flush, if we haven't already (at least with the + * current batchbuffer implementation, we have). + */ + + fence = intelEmitIrqLocked(intelScreen); + + return fence; +} + +/** Driver-specific fence wait implementation for the fake memory manager. */ +static int +intel_fence_wait(void *private, unsigned int cookie) +{ + intelScreenPrivate *intelScreen = (intelScreenPrivate *)private; + + intelWaitIrq(intelScreen, cookie); + + return 0; +} + +static GLboolean +intel_init_bufmgr(intelScreenPrivate *intelScreen) +{ + GLboolean gem_disable = getenv("INTEL_NO_GEM") != NULL; + int gem_kernel = 0; + GLboolean gem_supported; + struct drm_i915_getparam gp; + __DRIscreenPrivate *spriv = intelScreen->driScrnPriv; + + intelScreen->no_hw = getenv("INTEL_NO_HW") != NULL; + + gp.param = I915_PARAM_HAS_GEM; + gp.value = &gem_kernel; + + (void) drmCommandWriteRead(spriv->fd, DRM_I915_GETPARAM, &gp, sizeof(gp)); + + /* If we've got a new enough DDX that's initializing GEM and giving us + * object handles for the shared buffers, use that. + */ + intelScreen->ttm = GL_FALSE; + if (intelScreen->driScrnPriv->dri2.enabled) + gem_supported = GL_TRUE; + else if (intelScreen->driScrnPriv->ddx_version.minor >= 9 && + gem_kernel && + intelScreen->front.bo_handle != -1) + gem_supported = GL_TRUE; + else + gem_supported = GL_FALSE; + + if (!gem_disable && gem_supported) { + intelScreen->bufmgr = intel_bufmgr_gem_init(spriv->fd, BATCH_SZ); + if (intelScreen->bufmgr != NULL) + intelScreen->ttm = GL_TRUE; + } + /* Otherwise, use the classic buffer manager. */ + if (intelScreen->bufmgr == NULL) { + if (gem_disable) { + fprintf(stderr, "GEM disabled. Using classic.\n"); + } else { + fprintf(stderr, "Failed to initialize GEM. " + "Falling back to classic.\n"); + } + + if (intelScreen->tex.size == 0) { + fprintf(stderr, "[%s:%u] Error initializing buffer manager.\n", + __func__, __LINE__); + return GL_FALSE; + } + + intelScreen->bufmgr = intel_bufmgr_fake_init(intelScreen->tex.offset, + intelScreen->tex.map, + intelScreen->tex.size, + intel_fence_emit, + intel_fence_wait, + intelScreen); + } + + /* XXX bufmgr should be per-screen, not per-context */ + intelScreen->ttm = intelScreen->ttm; + + return GL_TRUE; +} + /** * This is the driver specific part of the createNewScreen entry point. * Called when using legacy DRI. @@ -562,6 +652,7 @@ intelFillInModes(__DRIscreenPrivate *psp, */ static const __DRIconfig **intelInitScreen(__DRIscreenPrivate *psp) { + intelScreenPrivate *intelScreen; #ifdef I915 static const __DRIversion ddx_expected = { 1, 5, 0 }; #else @@ -595,6 +686,10 @@ static const __DRIconfig **intelInitScreen(__DRIscreenPrivate *psp) psp->extensions = intelScreenExtensions; + intelScreen = psp->private; + if (!intel_init_bufmgr(intelScreen)) + return GL_FALSE; + return (const __DRIconfig **) intelFillInModes(psp, dri_priv->cpp * 8, (dri_priv->cpp == 2) ? 16 : 24, @@ -659,6 +754,9 @@ __DRIconfig **intelInitScreen2(__DRIscreenPrivate *psp) &intelScreen->deviceID)) return GL_FALSE; + if (!intel_init_bufmgr(intelScreen)) + return GL_FALSE; + intelScreen->irq_active = 1; psp->extensions = intelScreenExtensions; diff --git a/src/mesa/drivers/dri/intel/intel_screen.h b/src/mesa/drivers/dri/intel/intel_screen.h index 9a73b13951..299da87210 100644 --- a/src/mesa/drivers/dri/intel/intel_screen.h +++ b/src/mesa/drivers/dri/intel/intel_screen.h @@ -30,6 +30,7 @@ #include #include "dri_util.h" +#include "dri_bufmgr.h" #include "i915_drm.h" #include "xmlconfig.h" @@ -74,7 +75,10 @@ typedef struct int irq_active; int allow_batchbuffer; + GLboolean no_hw; + int ttm; + dri_bufmgr *bufmgr; /** * Configuration cache with default values for all contexts -- cgit v1.2.3 From 3628185f566e178a12b493fb89abf52b4b281f99 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Sat, 6 Sep 2008 03:09:43 +0100 Subject: intel: track bufmgr move to libdrm_intel and bufmgr_fake irq emit/wait change. --- src/mesa/drivers/dri/i915/Makefile | 2 + src/mesa/drivers/dri/i915/i830_texstate.c | 1 - src/mesa/drivers/dri/i915/i915_texstate.c | 1 - src/mesa/drivers/dri/i965/Makefile | 2 + src/mesa/drivers/dri/i965/brw_cc.c | 12 ++--- src/mesa/drivers/dri/i965/brw_clip_state.c | 12 ++--- src/mesa/drivers/dri/i965/brw_draw.h | 1 - src/mesa/drivers/dri/i965/brw_gs_state.c | 10 ++-- src/mesa/drivers/dri/i965/brw_sf_state.c | 20 ++++---- src/mesa/drivers/dri/i965/brw_state_upload.c | 1 - src/mesa/drivers/dri/i965/brw_vs_state.c | 10 ++-- src/mesa/drivers/dri/i965/brw_wm_sampler_state.c | 12 ++--- src/mesa/drivers/dri/i965/brw_wm_state.c | 31 ++++++------ src/mesa/drivers/dri/i965/brw_wm_surface_state.c | 34 ++++++------- src/mesa/drivers/dri/intel/intel_batchbuffer.c | 12 ++--- src/mesa/drivers/dri/intel/intel_batchbuffer.h | 2 +- src/mesa/drivers/dri/intel/intel_blit.h | 1 - src/mesa/drivers/dri/intel/intel_buffer_objects.c | 1 - src/mesa/drivers/dri/intel/intel_context.c | 6 +-- src/mesa/drivers/dri/intel/intel_context.h | 1 - src/mesa/drivers/dri/intel/intel_ioctl.c | 60 ----------------------- src/mesa/drivers/dri/intel/intel_ioctl.h | 3 -- src/mesa/drivers/dri/intel/intel_regions.c | 1 - src/mesa/drivers/dri/intel/intel_regions.h | 4 +- src/mesa/drivers/dri/intel/intel_screen.c | 47 ++++-------------- src/mesa/drivers/dri/intel/intel_screen.h | 5 +- 26 files changed, 96 insertions(+), 196 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/i915/Makefile b/src/mesa/drivers/dri/i915/Makefile index fd77980ebf..8f09c9f71e 100644 --- a/src/mesa/drivers/dri/i915/Makefile +++ b/src/mesa/drivers/dri/i915/Makefile @@ -64,6 +64,8 @@ DRIVER_DEFINES = -I../intel -I../intel/server -DI915 \ $(shell pkg-config libdrm --atleast-version=2.3.1 \ && echo "-DDRM_VBLANK_FLIP=DRM_VBLANK_FLIP") +DRI_LIB_DEPS += -ldrm_intel + include ../Makefile.template intel_decode.o: ../intel/intel_decode.c diff --git a/src/mesa/drivers/dri/i915/i830_texstate.c b/src/mesa/drivers/dri/i915/i830_texstate.c index 4e9b022eae..314bbe32b6 100644 --- a/src/mesa/drivers/dri/i915/i830_texstate.c +++ b/src/mesa/drivers/dri/i915/i830_texstate.c @@ -28,7 +28,6 @@ #include "mtypes.h" #include "enums.h" #include "texformat.h" -#include "dri_bufmgr.h" #include "intel_mipmap_tree.h" #include "intel_tex.h" diff --git a/src/mesa/drivers/dri/i915/i915_texstate.c b/src/mesa/drivers/dri/i915/i915_texstate.c index 1b1122cd8a..48137f025f 100644 --- a/src/mesa/drivers/dri/i915/i915_texstate.c +++ b/src/mesa/drivers/dri/i915/i915_texstate.c @@ -28,7 +28,6 @@ #include "mtypes.h" #include "enums.h" #include "texformat.h" -#include "dri_bufmgr.h" #include "intel_mipmap_tree.h" #include "intel_tex.h" diff --git a/src/mesa/drivers/dri/i965/Makefile b/src/mesa/drivers/dri/i965/Makefile index 8fa205e79f..e72790c687 100644 --- a/src/mesa/drivers/dri/i965/Makefile +++ b/src/mesa/drivers/dri/i965/Makefile @@ -91,6 +91,8 @@ ASM_SOURCES = DRIVER_DEFINES = -I../intel -I../intel/server +DRI_LIB_DEPS += -ldrm_intel + include ../Makefile.template symlinks: diff --git a/src/mesa/drivers/dri/i965/brw_cc.c b/src/mesa/drivers/dri/i965/brw_cc.c index d662cf7521..0458bf5983 100644 --- a/src/mesa/drivers/dri/i965/brw_cc.c +++ b/src/mesa/drivers/dri/i965/brw_cc.c @@ -255,12 +255,12 @@ cc_unit_create_from_key(struct brw_context *brw, struct brw_cc_unit_key *key) NULL, NULL); /* Emit CC viewport relocation */ - intel_bo_emit_reloc(bo, - I915_GEM_DOMAIN_INSTRUCTION, - 0, - 0, - offsetof(struct brw_cc_unit_state, cc4), - brw->cc.vp_bo); + dri_bo_emit_reloc(bo, + I915_GEM_DOMAIN_INSTRUCTION, + 0, + 0, + offsetof(struct brw_cc_unit_state, cc4), + brw->cc.vp_bo); return bo; } diff --git a/src/mesa/drivers/dri/i965/brw_clip_state.c b/src/mesa/drivers/dri/i965/brw_clip_state.c index ae904c6253..51045f9188 100644 --- a/src/mesa/drivers/dri/i965/brw_clip_state.c +++ b/src/mesa/drivers/dri/i965/brw_clip_state.c @@ -119,12 +119,12 @@ clip_unit_create_from_key(struct brw_context *brw, /* Emit clip program relocation */ assert(brw->clip.prog_bo); - intel_bo_emit_reloc(bo, - I915_GEM_DOMAIN_INSTRUCTION, - 0, - clip.thread0.grf_reg_count << 1, - offsetof(struct brw_clip_unit_state, thread0), - brw->clip.prog_bo); + dri_bo_emit_reloc(bo, + I915_GEM_DOMAIN_INSTRUCTION, + 0, + clip.thread0.grf_reg_count << 1, + offsetof(struct brw_clip_unit_state, thread0), + brw->clip.prog_bo); return bo; } diff --git a/src/mesa/drivers/dri/i965/brw_draw.h b/src/mesa/drivers/dri/i965/brw_draw.h index 2a3e0c1c5b..e0bba589d5 100644 --- a/src/mesa/drivers/dri/i965/brw_draw.h +++ b/src/mesa/drivers/dri/i965/brw_draw.h @@ -31,7 +31,6 @@ #include "mtypes.h" /* for GLcontext... */ #include "vbo/vbo.h" -#include "dri_bufmgr.h" struct brw_context; diff --git a/src/mesa/drivers/dri/i965/brw_gs_state.c b/src/mesa/drivers/dri/i965/brw_gs_state.c index ff2e3ab059..633e17cc9d 100644 --- a/src/mesa/drivers/dri/i965/brw_gs_state.c +++ b/src/mesa/drivers/dri/i965/brw_gs_state.c @@ -106,11 +106,11 @@ gs_unit_create_from_key(struct brw_context *brw, struct brw_gs_unit_key *key) if (key->prog_active) { /* Emit GS program relocation */ - intel_bo_emit_reloc(bo, - I915_GEM_DOMAIN_INSTRUCTION, 0, - gs.thread0.grf_reg_count << 1, - offsetof(struct brw_gs_unit_state, thread0), - brw->gs.prog_bo); + dri_bo_emit_reloc(bo, + I915_GEM_DOMAIN_INSTRUCTION, 0, + gs.thread0.grf_reg_count << 1, + offsetof(struct brw_gs_unit_state, thread0), + brw->gs.prog_bo); } return bo; diff --git a/src/mesa/drivers/dri/i965/brw_sf_state.c b/src/mesa/drivers/dri/i965/brw_sf_state.c index 2478872b82..07d0b4c798 100644 --- a/src/mesa/drivers/dri/i965/brw_sf_state.c +++ b/src/mesa/drivers/dri/i965/brw_sf_state.c @@ -251,18 +251,18 @@ sf_unit_create_from_key(struct brw_context *brw, struct brw_sf_unit_key *key, NULL, NULL); /* Emit SF program relocation */ - intel_bo_emit_reloc(bo, - I915_GEM_DOMAIN_INSTRUCTION, 0, - sf.thread0.grf_reg_count << 1, - offsetof(struct brw_sf_unit_state, thread0), - brw->sf.prog_bo); + dri_bo_emit_reloc(bo, + I915_GEM_DOMAIN_INSTRUCTION, 0, + sf.thread0.grf_reg_count << 1, + offsetof(struct brw_sf_unit_state, thread0), + brw->sf.prog_bo); /* Emit SF viewport relocation */ - intel_bo_emit_reloc(bo, - I915_GEM_DOMAIN_INSTRUCTION, 0, - sf.sf5.front_winding | (sf.sf5.viewport_transform << 1), - offsetof(struct brw_sf_unit_state, sf5), - brw->sf.vp_bo); + dri_bo_emit_reloc(bo, + I915_GEM_DOMAIN_INSTRUCTION, 0, + sf.sf5.front_winding | (sf.sf5.viewport_transform << 1), + offsetof(struct brw_sf_unit_state, sf5), + brw->sf.vp_bo); return bo; } diff --git a/src/mesa/drivers/dri/i965/brw_state_upload.c b/src/mesa/drivers/dri/i965/brw_state_upload.c index d1d319d92e..7d4fd467b1 100644 --- a/src/mesa/drivers/dri/i965/brw_state_upload.c +++ b/src/mesa/drivers/dri/i965/brw_state_upload.c @@ -33,7 +33,6 @@ #include "brw_context.h" #include "brw_state.h" -#include "dri_bufmgr.h" #include "intel_batchbuffer.h" /* This is used to initialize brw->state.atoms[]. We could use this diff --git a/src/mesa/drivers/dri/i965/brw_vs_state.c b/src/mesa/drivers/dri/i965/brw_vs_state.c index 909b942610..24bf5567bd 100644 --- a/src/mesa/drivers/dri/i965/brw_vs_state.c +++ b/src/mesa/drivers/dri/i965/brw_vs_state.c @@ -115,11 +115,11 @@ vs_unit_create_from_key(struct brw_context *brw, struct brw_vs_unit_key *key) NULL, NULL); /* Emit VS program relocation */ - intel_bo_emit_reloc(bo, - I915_GEM_DOMAIN_INSTRUCTION, 0, - vs.thread0.grf_reg_count << 1, - offsetof(struct brw_vs_unit_state, thread0), - brw->vs.prog_bo); + dri_bo_emit_reloc(bo, + I915_GEM_DOMAIN_INSTRUCTION, 0, + vs.thread0.grf_reg_count << 1, + offsetof(struct brw_vs_unit_state, thread0), + brw->vs.prog_bo); return bo; } diff --git a/src/mesa/drivers/dri/i965/brw_wm_sampler_state.c b/src/mesa/drivers/dri/i965/brw_wm_sampler_state.c index 08d01823de..e47dbe8b10 100644 --- a/src/mesa/drivers/dri/i965/brw_wm_sampler_state.c +++ b/src/mesa/drivers/dri/i965/brw_wm_sampler_state.c @@ -303,12 +303,12 @@ static void upload_wm_samplers( struct brw_context *brw ) if (!brw->attribs.Texture->Unit[i]._ReallyEnabled) continue; - intel_bo_emit_reloc(brw->wm.sampler_bo, - I915_GEM_DOMAIN_INSTRUCTION, 0, - 0, - i * sizeof(struct brw_sampler_state) + - offsetof(struct brw_sampler_state, ss2), - brw->wm.sdc_bo[i]); + dri_bo_emit_reloc(brw->wm.sampler_bo, + I915_GEM_DOMAIN_INSTRUCTION, 0, + 0, + i * sizeof(struct brw_sampler_state) + + offsetof(struct brw_sampler_state, ss2), + brw->wm.sdc_bo[i]); } } } diff --git a/src/mesa/drivers/dri/i965/brw_wm_state.c b/src/mesa/drivers/dri/i965/brw_wm_state.c index f97d0dc285..61fe97a463 100644 --- a/src/mesa/drivers/dri/i965/brw_wm_state.c +++ b/src/mesa/drivers/dri/i965/brw_wm_state.c @@ -34,7 +34,6 @@ #include "brw_context.h" #include "brw_state.h" #include "brw_defines.h" -#include "dri_bufmgr.h" #include "brw_wm.h" /*********************************************************************** @@ -199,28 +198,28 @@ wm_unit_create_from_key(struct brw_context *brw, struct brw_wm_unit_key *key, NULL, NULL); /* Emit WM program relocation */ - intel_bo_emit_reloc(bo, - I915_GEM_DOMAIN_INSTRUCTION, 0, - wm.thread0.grf_reg_count << 1, - offsetof(struct brw_wm_unit_state, thread0), - brw->wm.prog_bo); + dri_bo_emit_reloc(bo, + I915_GEM_DOMAIN_INSTRUCTION, 0, + wm.thread0.grf_reg_count << 1, + offsetof(struct brw_wm_unit_state, thread0), + brw->wm.prog_bo); /* Emit scratch space relocation */ if (key->total_scratch != 0) { - intel_bo_emit_reloc(bo, - 0, 0, - wm.thread2.per_thread_scratch_space, - offsetof(struct brw_wm_unit_state, thread2), - brw->wm.scratch_buffer); + dri_bo_emit_reloc(bo, + 0, 0, + wm.thread2.per_thread_scratch_space, + offsetof(struct brw_wm_unit_state, thread2), + brw->wm.scratch_buffer); } /* Emit sampler state relocation */ if (key->sampler_count != 0) { - intel_bo_emit_reloc(bo, - I915_GEM_DOMAIN_INSTRUCTION, 0, - wm.wm4.stats_enable | (wm.wm4.sampler_count << 2), - offsetof(struct brw_wm_unit_state, wm4), - brw->wm.sampler_bo); + dri_bo_emit_reloc(bo, + I915_GEM_DOMAIN_INSTRUCTION, 0, + wm.wm4.stats_enable | (wm.wm4.sampler_count << 2), + offsetof(struct brw_wm_unit_state, wm4), + brw->wm.sampler_bo); } return bo; diff --git a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c index 493d2b182c..8fcd50924f 100644 --- a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c +++ b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c @@ -234,11 +234,11 @@ brw_create_texture_surface( struct brw_context *brw, if (key->bo) { /* Emit relocation to surface contents */ - intel_bo_emit_reloc(bo, - I915_GEM_DOMAIN_SAMPLER, 0, - 0, - offsetof(struct brw_surface_state, ss1), - key->bo); + dri_bo_emit_reloc(bo, + I915_GEM_DOMAIN_SAMPLER, 0, + 0, + offsetof(struct brw_surface_state, ss1), + key->bo); } return bo; } @@ -374,13 +374,13 @@ brw_update_region_surface(struct brw_context *brw, struct intel_region *region, * them both. We might be able to figure out from other state * a more restrictive relocation to emit. */ - intel_bo_emit_reloc(brw->wm.surf_bo[unit], - I915_GEM_DOMAIN_RENDER | - I915_GEM_DOMAIN_SAMPLER, - I915_GEM_DOMAIN_RENDER, - 0, - offsetof(struct brw_surface_state, ss1), - region_bo); + dri_bo_emit_reloc(brw->wm.surf_bo[unit], + I915_GEM_DOMAIN_RENDER | + I915_GEM_DOMAIN_SAMPLER, + I915_GEM_DOMAIN_RENDER, + 0, + offsetof(struct brw_surface_state, ss1), + region_bo); } } } @@ -420,11 +420,11 @@ brw_wm_get_binding_table(struct brw_context *brw) /* Emit binding table relocations to surface state */ for (i = 0; i < BRW_WM_MAX_SURF; i++) { if (brw->wm.surf_bo[i] != NULL) { - intel_bo_emit_reloc(bind_bo, - I915_GEM_DOMAIN_INSTRUCTION, 0, - 0, - i * sizeof(GLuint), - brw->wm.surf_bo[i]); + dri_bo_emit_reloc(bind_bo, + I915_GEM_DOMAIN_INSTRUCTION, 0, + 0, + i * sizeof(GLuint), + brw->wm.surf_bo[i]); } } diff --git a/src/mesa/drivers/dri/intel/intel_batchbuffer.c b/src/mesa/drivers/dri/intel/intel_batchbuffer.c index 550f467f83..9671232343 100644 --- a/src/mesa/drivers/dri/intel/intel_batchbuffer.c +++ b/src/mesa/drivers/dri/intel/intel_batchbuffer.c @@ -261,13 +261,9 @@ _intel_batchbuffer_flush(struct intel_batchbuffer *batch, const char *file, UNLOCK_HARDWARE(intel); if (INTEL_DEBUG & DEBUG_SYNC) { - int irq; - fprintf(stderr, "waiting for idle\n"); - LOCK_HARDWARE(intel); - irq = intelEmitIrqLocked(intel->intelScreen); - UNLOCK_HARDWARE(intel); - intelWaitIrq(intel->intelScreen, irq); + dri_bo_map(batch->buf, GL_TRUE); + dri_bo_unmap(batch->buf); } /* Reset the buffer: @@ -289,8 +285,8 @@ intel_batchbuffer_emit_reloc(struct intel_batchbuffer *batch, if (batch->ptr - batch->map > batch->buf->size) _mesa_printf ("bad relocation ptr %p map %p offset %d size %d\n", batch->ptr, batch->map, batch->ptr - batch->map, batch->buf->size); - ret = intel_bo_emit_reloc(batch->buf, read_domains, write_domain, - delta, batch->ptr - batch->map, buffer); + ret = dri_bo_emit_reloc(batch->buf, read_domains, write_domain, + delta, batch->ptr - batch->map, buffer); /* * Using the old buffer offset, write in what the right data would be, in case diff --git a/src/mesa/drivers/dri/intel/intel_batchbuffer.h b/src/mesa/drivers/dri/intel/intel_batchbuffer.h index 52d6ecc223..7ede1b8903 100644 --- a/src/mesa/drivers/dri/intel/intel_batchbuffer.h +++ b/src/mesa/drivers/dri/intel/intel_batchbuffer.h @@ -3,7 +3,7 @@ #include "mtypes.h" -#include "dri_bufmgr.h" +#include "intel_bufmgr.h" #include "intel_reg.h" struct intel_context; diff --git a/src/mesa/drivers/dri/intel/intel_blit.h b/src/mesa/drivers/dri/intel/intel_blit.h index 0881cc4fdc..60e30f21e8 100644 --- a/src/mesa/drivers/dri/intel/intel_blit.h +++ b/src/mesa/drivers/dri/intel/intel_blit.h @@ -30,7 +30,6 @@ #include "intel_context.h" #include "intel_ioctl.h" -#include "dri_bufmgr.h" extern void intelCopyBuffer(const __DRIdrawablePrivate * dpriv, const drm_clip_rect_t * rect); diff --git a/src/mesa/drivers/dri/intel/intel_buffer_objects.c b/src/mesa/drivers/dri/intel/intel_buffer_objects.c index 1923a21516..88484a07af 100644 --- a/src/mesa/drivers/dri/intel/intel_buffer_objects.c +++ b/src/mesa/drivers/dri/intel/intel_buffer_objects.c @@ -34,7 +34,6 @@ #include "intel_buffer_objects.h" #include "intel_batchbuffer.h" #include "intel_regions.h" -#include "dri_bufmgr.h" static GLboolean intel_bufferobj_unmap(GLcontext * ctx, GLenum target, diff --git a/src/mesa/drivers/dri/intel/intel_context.c b/src/mesa/drivers/dri/intel/intel_context.c index 15ab9cbf35..591b521664 100644 --- a/src/mesa/drivers/dri/intel/intel_context.c +++ b/src/mesa/drivers/dri/intel/intel_context.c @@ -278,7 +278,7 @@ intel_update_renderbuffers(__DRIcontext *context, __DRIdrawable *drawable) } if (rb->region) { - intel_bo_flink(rb->region->buffer, &name); + dri_bo_flink(rb->region->buffer, &name); if (name == buffers[i].name) continue; } @@ -614,8 +614,6 @@ intelInitContext(struct intel_context *intel, GLcontext *shareCtx = (GLcontext *) sharedContextPrivate; __DRIscreenPrivate *sPriv = driContextPriv->driScreenPriv; intelScreenPrivate *intelScreen = (intelScreenPrivate *) sPriv->private; - volatile struct drm_i915_sarea *saPriv = (struct drm_i915_sarea *) - (((GLubyte *) sPriv->pSAREA) + intelScreen->sarea_priv_offset); int fthrottle_mode; if (!_mesa_initialize_context(&intel->ctx, mesaVis, shareCtx, @@ -627,7 +625,7 @@ intelInitContext(struct intel_context *intel, driContextPriv->driverPrivate = intel; intel->intelScreen = intelScreen; intel->driScreen = sPriv; - intel->sarea = saPriv; + intel->sarea = intelScreen->sarea; intel->driContext = driContextPriv; /* Dri stuff */ diff --git a/src/mesa/drivers/dri/intel/intel_context.h b/src/mesa/drivers/dri/intel/intel_context.h index 04a20278d1..8bd75753ea 100644 --- a/src/mesa/drivers/dri/intel/intel_context.h +++ b/src/mesa/drivers/dri/intel/intel_context.h @@ -34,7 +34,6 @@ #include "drm.h" #include "mm.h" #include "texmem.h" -#include "dri_bufmgr.h" #include "intel_bufmgr.h" #include "intel_screen.h" diff --git a/src/mesa/drivers/dri/intel/intel_ioctl.c b/src/mesa/drivers/dri/intel/intel_ioctl.c index ac9e9337d6..c58a803505 100644 --- a/src/mesa/drivers/dri/intel/intel_ioctl.c +++ b/src/mesa/drivers/dri/intel/intel_ioctl.c @@ -49,66 +49,6 @@ #define FILE_DEBUG_FLAG DEBUG_IOCTL -int -intelEmitIrqLocked(intelScreenPrivate *intelScreen) -{ - __DRIscreenPrivate *spriv = intelScreen->driScrnPriv; - struct drm_i915_irq_emit ie; - int ret, seq = 1; - - if (intelScreen->no_hw) - return 1; - - /* - assert(((*(int *)intelScreen->driHwLock) & ~DRM_LOCK_CONT) == - (DRM_LOCK_HELD|intelScreen->hHWContext)); - */ - - ie.irq_seq = &seq; - - ret = drmCommandWriteRead(spriv->fd, DRM_I915_IRQ_EMIT, &ie, sizeof(ie)); - if (ret) { - fprintf(stderr, "%s: drm_i915_irq_emit: %d\n", __FUNCTION__, ret); - exit(1); - } - - DBG("%s --> %d\n", __FUNCTION__, seq); - - return seq; -} - -void -intelWaitIrq(intelScreenPrivate *intelScreen, int seq) -{ - __DRIscreenPrivate *spriv = intelScreen->driScrnPriv; - struct drm_i915_irq_wait iw; - int ret, lastdispatch; - volatile struct drm_i915_sarea *sarea = (struct drm_i915_sarea *) - (((GLubyte *) spriv->pSAREA) + intelScreen->sarea_priv_offset); - - if (intelScreen->no_hw) - return; - - DBG("%s %d\n", __FUNCTION__, seq); - - iw.irq_seq = seq; - - do { - lastdispatch = sarea->last_dispatch; - ret = drmCommandWrite(spriv->fd, DRM_I915_IRQ_WAIT, &iw, sizeof(iw)); - } while (ret == -EAGAIN || - ret == -EINTR || - (ret == -EBUSY && lastdispatch != sarea->last_dispatch) || - (ret == 0 && seq > sarea->last_dispatch) || - (ret == 0 && sarea->last_dispatch - seq >= (1 << 24))); - - if (ret) { - fprintf(stderr, "%s: drm_i915_irq_wait: %d\n", __FUNCTION__, ret); - exit(1); - } -} - - int intel_batch_ioctl(struct intel_context *intel, GLuint start_offset, diff --git a/src/mesa/drivers/dri/intel/intel_ioctl.h b/src/mesa/drivers/dri/intel/intel_ioctl.h index 2ea40001db..6736856dbd 100644 --- a/src/mesa/drivers/dri/intel/intel_ioctl.h +++ b/src/mesa/drivers/dri/intel/intel_ioctl.h @@ -30,9 +30,6 @@ #include "intel_context.h" -void intelWaitIrq(intelScreenPrivate *intelScreen, int seq); -int intelEmitIrqLocked(intelScreenPrivate *intelScreen); - int intel_batch_ioctl(struct intel_context *intel, GLuint start_offset, GLuint used, diff --git a/src/mesa/drivers/dri/intel/intel_regions.c b/src/mesa/drivers/dri/intel/intel_regions.c index c86c1034a9..1cfc8ddd64 100644 --- a/src/mesa/drivers/dri/intel/intel_regions.c +++ b/src/mesa/drivers/dri/intel/intel_regions.c @@ -46,7 +46,6 @@ #include "intel_regions.h" #include "intel_blit.h" #include "intel_buffer_objects.h" -#include "dri_bufmgr.h" #include "intel_bufmgr.h" #include "intel_batchbuffer.h" #include "intel_chipset.h" diff --git a/src/mesa/drivers/dri/intel/intel_regions.h b/src/mesa/drivers/dri/intel/intel_regions.h index 1285f250a7..a561de485e 100644 --- a/src/mesa/drivers/dri/intel/intel_regions.h +++ b/src/mesa/drivers/dri/intel/intel_regions.h @@ -34,8 +34,10 @@ * the basic structure for rectangular collections of pixels stored in a dri_bo. */ +#include + #include "mtypes.h" -#include "dri_bufmgr.h" +#include "intel_bufmgr.h" struct intel_context; struct intel_buffer_object; diff --git a/src/mesa/drivers/dri/intel/intel_screen.c b/src/mesa/drivers/dri/intel/intel_screen.c index 5cfb893305..2355eafeca 100644 --- a/src/mesa/drivers/dri/intel/intel_screen.c +++ b/src/mesa/drivers/dri/intel/intel_screen.c @@ -274,9 +274,9 @@ static GLboolean intelInitDriver(__DRIscreenPrivate *sPriv) intelScreen->driScrnPriv = sPriv; sPriv->private = (void *) intelScreen; - intelScreen->sarea_priv_offset = gDRIPriv->sarea_priv_offset; sarea = (struct drm_i915_sarea *) - (((GLubyte *) sPriv->pSAREA) + intelScreen->sarea_priv_offset); + (((GLubyte *) sPriv->pSAREA) + gDRIPriv->sarea_priv_offset); + intelScreen->sarea = sarea; intelScreen->deviceID = gDRIPriv->deviceID; @@ -289,8 +289,6 @@ static GLboolean intelInitDriver(__DRIscreenPrivate *sPriv) return GL_FALSE; } - intelScreen->sarea_priv_offset = gDRIPriv->sarea_priv_offset; - if (0) intelPrintDRIInfo(intelScreen, sPriv, gDRIPriv); @@ -551,34 +549,6 @@ intelFillInModes(__DRIscreenPrivate *psp, return configs; } - -/** Driver-specific fence emit implementation for the fake memory manager. */ -static unsigned int -intel_fence_emit(void *private) -{ - intelScreenPrivate *intelScreen = (intelScreenPrivate *)private; - unsigned int fence; - - /* XXX: Need to emit a flush, if we haven't already (at least with the - * current batchbuffer implementation, we have). - */ - - fence = intelEmitIrqLocked(intelScreen); - - return fence; -} - -/** Driver-specific fence wait implementation for the fake memory manager. */ -static int -intel_fence_wait(void *private, unsigned int cookie) -{ - intelScreenPrivate *intelScreen = (intelScreenPrivate *)private; - - intelWaitIrq(intelScreen, cookie); - - return 0; -} - static GLboolean intel_init_bufmgr(intelScreenPrivate *intelScreen) { @@ -628,12 +598,13 @@ intel_init_bufmgr(intelScreenPrivate *intelScreen) return GL_FALSE; } - intelScreen->bufmgr = intel_bufmgr_fake_init(intelScreen->tex.offset, - intelScreen->tex.map, - intelScreen->tex.size, - intel_fence_emit, - intel_fence_wait, - intelScreen); + intelScreen->bufmgr = + intel_bufmgr_fake_init(spriv->fd, + intelScreen->tex.offset, + intelScreen->tex.map, + intelScreen->tex.size, + (unsigned int * volatile) + &intelScreen->sarea->last_dispatch); } /* XXX bufmgr should be per-screen, not per-context */ diff --git a/src/mesa/drivers/dri/intel/intel_screen.h b/src/mesa/drivers/dri/intel/intel_screen.h index 299da87210..daf2ab4c58 100644 --- a/src/mesa/drivers/dri/intel/intel_screen.h +++ b/src/mesa/drivers/dri/intel/intel_screen.h @@ -30,7 +30,7 @@ #include #include "dri_util.h" -#include "dri_bufmgr.h" +#include "intel_bufmgr.h" #include "i915_drm.h" #include "xmlconfig.h" @@ -68,7 +68,8 @@ typedef struct int logTextureGranularity; __DRIscreenPrivate *driScrnPriv; - unsigned int sarea_priv_offset; + + volatile struct drm_i915_sarea *sarea; int drmMinor; -- cgit v1.2.3 From 35fd72756a05463568d94862f4fcd234903e1204 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Mon, 8 Sep 2008 08:52:48 -0700 Subject: intel: track move of bo_exec from drivers to bufmgr. --- src/mesa/drivers/dri/i915/Makefile | 1 - src/mesa/drivers/dri/i915/i830_metaops.c | 1 - src/mesa/drivers/dri/i915/i830_tex.c | 2 - src/mesa/drivers/dri/i915/i830_texblend.c | 1 - src/mesa/drivers/dri/i915/i915_metaops.c | 1 - src/mesa/drivers/dri/i915/i915_tex.c | 2 - src/mesa/drivers/dri/i915/intel_ioctl.c | 1 - src/mesa/drivers/dri/i915/intel_pixel_read.c | 1 - src/mesa/drivers/dri/i965/Makefile | 1 - src/mesa/drivers/dri/i965/brw_draw.c | 1 - src/mesa/drivers/dri/i965/brw_draw_upload.c | 1 - src/mesa/drivers/dri/i965/brw_tex.c | 1 - src/mesa/drivers/dri/i965/intel_ioctl.c | 1 - src/mesa/drivers/dri/intel/intel_batchbuffer.c | 29 ++---- src/mesa/drivers/dri/intel/intel_batchbuffer.h | 3 +- src/mesa/drivers/dri/intel/intel_blit.c | 2 +- src/mesa/drivers/dri/intel/intel_blit.h | 1 - src/mesa/drivers/dri/intel/intel_context.c | 1 - src/mesa/drivers/dri/intel/intel_ioctl.c | 128 ------------------------ src/mesa/drivers/dri/intel/intel_ioctl.h | 43 -------- src/mesa/drivers/dri/intel/intel_pixel_bitmap.c | 1 - src/mesa/drivers/dri/intel/intel_pixel_copy.c | 1 - src/mesa/drivers/dri/intel/intel_pixel_draw.c | 1 - src/mesa/drivers/dri/intel/intel_screen.c | 1 - src/mesa/drivers/dri/intel/intel_span.c | 1 - src/mesa/drivers/dri/intel/intel_tex_image.c | 1 - 26 files changed, 10 insertions(+), 218 deletions(-) delete mode 120000 src/mesa/drivers/dri/i915/intel_ioctl.c delete mode 120000 src/mesa/drivers/dri/i965/intel_ioctl.c delete mode 100644 src/mesa/drivers/dri/intel/intel_ioctl.c delete mode 100644 src/mesa/drivers/dri/intel/intel_ioctl.h (limited to 'src') diff --git a/src/mesa/drivers/dri/i915/Makefile b/src/mesa/drivers/dri/i915/Makefile index 8f09c9f71e..5858e0ee9f 100644 --- a/src/mesa/drivers/dri/i915/Makefile +++ b/src/mesa/drivers/dri/i915/Makefile @@ -46,7 +46,6 @@ DRIVER_SOURCES = \ i915_vtbl.c \ intel_context.c \ intel_decode.c \ - intel_ioctl.c \ intel_screen.c \ intel_span.c \ intel_state.c \ diff --git a/src/mesa/drivers/dri/i915/i830_metaops.c b/src/mesa/drivers/dri/i915/i830_metaops.c index 13e4ab3aac..acfb3af910 100644 --- a/src/mesa/drivers/dri/i915/i830_metaops.c +++ b/src/mesa/drivers/dri/i915/i830_metaops.c @@ -33,7 +33,6 @@ #include "intel_screen.h" #include "intel_batchbuffer.h" -#include "intel_ioctl.h" #include "intel_regions.h" #include "i830_context.h" diff --git a/src/mesa/drivers/dri/i915/i830_tex.c b/src/mesa/drivers/dri/i915/i830_tex.c index 79b0fcf596..c0126ba19a 100644 --- a/src/mesa/drivers/dri/i915/i830_tex.c +++ b/src/mesa/drivers/dri/i915/i830_tex.c @@ -38,8 +38,6 @@ #include "mm.h" -#include "intel_ioctl.h" - #include "i830_context.h" #include "i830_reg.h" diff --git a/src/mesa/drivers/dri/i915/i830_texblend.c b/src/mesa/drivers/dri/i915/i830_texblend.c index 58f220eb7c..dca72adeca 100644 --- a/src/mesa/drivers/dri/i915/i830_texblend.c +++ b/src/mesa/drivers/dri/i915/i830_texblend.c @@ -36,7 +36,6 @@ #include "mm.h" #include "intel_screen.h" -#include "intel_ioctl.h" #include "intel_tex.h" #include "i830_context.h" diff --git a/src/mesa/drivers/dri/i915/i915_metaops.c b/src/mesa/drivers/dri/i915/i915_metaops.c index 73aa63451e..bfe97f13e5 100644 --- a/src/mesa/drivers/dri/i915/i915_metaops.c +++ b/src/mesa/drivers/dri/i915/i915_metaops.c @@ -33,7 +33,6 @@ #include "intel_screen.h" #include "intel_batchbuffer.h" -#include "intel_ioctl.h" #include "intel_regions.h" #include "i915_context.h" diff --git a/src/mesa/drivers/dri/i915/i915_tex.c b/src/mesa/drivers/dri/i915/i915_tex.c index 386617a1ff..cb55bf6125 100644 --- a/src/mesa/drivers/dri/i915/i915_tex.c +++ b/src/mesa/drivers/dri/i915/i915_tex.c @@ -38,8 +38,6 @@ #include "mm.h" -#include "intel_ioctl.h" - #include "i915_context.h" #include "i915_reg.h" diff --git a/src/mesa/drivers/dri/i915/intel_ioctl.c b/src/mesa/drivers/dri/i915/intel_ioctl.c deleted file mode 120000 index effd0f378d..0000000000 --- a/src/mesa/drivers/dri/i915/intel_ioctl.c +++ /dev/null @@ -1 +0,0 @@ -../intel/intel_ioctl.c \ No newline at end of file diff --git a/src/mesa/drivers/dri/i915/intel_pixel_read.c b/src/mesa/drivers/dri/i915/intel_pixel_read.c index d009590a4b..120c887abd 100644 --- a/src/mesa/drivers/dri/i915/intel_pixel_read.c +++ b/src/mesa/drivers/dri/i915/intel_pixel_read.c @@ -35,7 +35,6 @@ #include "intel_screen.h" #include "intel_context.h" -#include "intel_ioctl.h" #include "intel_batchbuffer.h" #include "intel_blit.h" #include "intel_buffers.h" diff --git a/src/mesa/drivers/dri/i965/Makefile b/src/mesa/drivers/dri/i965/Makefile index e72790c687..c2d555cd0c 100644 --- a/src/mesa/drivers/dri/i965/Makefile +++ b/src/mesa/drivers/dri/i965/Makefile @@ -13,7 +13,6 @@ DRIVER_SOURCES = \ intel_decode.c \ intel_depthstencil.c \ intel_fbo.c \ - intel_ioctl.c \ intel_mipmap_tree.c \ intel_regions.c \ intel_screen.c \ diff --git a/src/mesa/drivers/dri/i965/brw_draw.c b/src/mesa/drivers/dri/i965/brw_draw.c index d43b52c2c7..95d798238d 100644 --- a/src/mesa/drivers/dri/i965/brw_draw.c +++ b/src/mesa/drivers/dri/i965/brw_draw.c @@ -39,7 +39,6 @@ #include "brw_state.h" #include "brw_fallback.h" -#include "intel_ioctl.h" #include "intel_batchbuffer.h" #include "intel_buffer_objects.h" diff --git a/src/mesa/drivers/dri/i965/brw_draw_upload.c b/src/mesa/drivers/dri/i965/brw_draw_upload.c index 0122d18f82..465239f195 100644 --- a/src/mesa/drivers/dri/i965/brw_draw_upload.c +++ b/src/mesa/drivers/dri/i965/brw_draw_upload.c @@ -39,7 +39,6 @@ #include "brw_state.h" #include "brw_fallback.h" -#include "intel_ioctl.h" #include "intel_batchbuffer.h" #include "intel_buffer_objects.h" #include "intel_tex.h" diff --git a/src/mesa/drivers/dri/i965/brw_tex.c b/src/mesa/drivers/dri/i965/brw_tex.c index 258c6260fb..ab6393420a 100644 --- a/src/mesa/drivers/dri/i965/brw_tex.c +++ b/src/mesa/drivers/dri/i965/brw_tex.c @@ -42,7 +42,6 @@ #include "texmem.h" #include "intel_context.h" -#include "intel_ioctl.h" #include "intel_regions.h" #include "intel_tex.h" #include "brw_context.h" diff --git a/src/mesa/drivers/dri/i965/intel_ioctl.c b/src/mesa/drivers/dri/i965/intel_ioctl.c deleted file mode 120000 index effd0f378d..0000000000 --- a/src/mesa/drivers/dri/i965/intel_ioctl.c +++ /dev/null @@ -1 +0,0 @@ -../intel/intel_ioctl.c \ No newline at end of file diff --git a/src/mesa/drivers/dri/intel/intel_batchbuffer.c b/src/mesa/drivers/dri/intel/intel_batchbuffer.c index 9671232343..7dbc646370 100644 --- a/src/mesa/drivers/dri/intel/intel_batchbuffer.c +++ b/src/mesa/drivers/dri/intel/intel_batchbuffer.c @@ -25,8 +25,8 @@ * **************************************************************************/ +#include "intel_context.h" #include "intel_batchbuffer.h" -#include "intel_ioctl.h" #include "intel_decode.h" #include "intel_reg.h" #include "intel_bufmgr.h" @@ -148,28 +148,15 @@ do_flush_locked(struct intel_batchbuffer *batch, */ if (!(intel->numClipRects == 0 && - batch->cliprect_mode == LOOP_CLIPRECTS)) { - if (intel->ttm == GL_TRUE) { - struct drm_i915_gem_execbuffer *execbuf; - - execbuf = dri_process_relocs(batch->buf); - ret = intel_exec_ioctl(batch->intel, - used, - batch->cliprect_mode != LOOP_CLIPRECTS, - allow_unlock, - execbuf); - } else { - dri_process_relocs(batch->buf); - ret = intel_batch_ioctl(batch->intel, - batch->buf->offset, - used, - batch->cliprect_mode != LOOP_CLIPRECTS, - allow_unlock); - } + batch->cliprect_mode == LOOP_CLIPRECTS) || intel->no_hw) { + dri_bo_exec(batch->buf, used, + intel->pClipRects, + batch->cliprect_mode != LOOP_CLIPRECTS ? + 0 : intel->numClipRects, + (((GLuint) intel->drawX) & 0xffff) | + (((GLuint) intel->drawY) << 16)); } - dri_post_submit(batch->buf); - if (intel->numClipRects == 0 && batch->cliprect_mode == LOOP_CLIPRECTS) { if (allow_unlock) { diff --git a/src/mesa/drivers/dri/intel/intel_batchbuffer.h b/src/mesa/drivers/dri/intel/intel_batchbuffer.h index 7ede1b8903..cf7d4a0633 100644 --- a/src/mesa/drivers/dri/intel/intel_batchbuffer.h +++ b/src/mesa/drivers/dri/intel/intel_batchbuffer.h @@ -3,11 +3,10 @@ #include "mtypes.h" +#include "intel_context.h" #include "intel_bufmgr.h" #include "intel_reg.h" -struct intel_context; - #define BATCH_SZ 16384 #define BATCH_RESERVED 16 diff --git a/src/mesa/drivers/dri/intel/intel_blit.c b/src/mesa/drivers/dri/intel/intel_blit.c index 7129a4ba91..653f485dd0 100644 --- a/src/mesa/drivers/dri/intel/intel_blit.c +++ b/src/mesa/drivers/dri/intel/intel_blit.c @@ -33,13 +33,13 @@ #include "context.h" #include "enums.h" -#include "intel_batchbuffer.h" #include "intel_blit.h" #include "intel_buffers.h" #include "intel_context.h" #include "intel_fbo.h" #include "intel_reg.h" #include "intel_regions.h" +#include "intel_batchbuffer.h" #define FILE_DEBUG_FLAG DEBUG_BLIT diff --git a/src/mesa/drivers/dri/intel/intel_blit.h b/src/mesa/drivers/dri/intel/intel_blit.h index 60e30f21e8..52065b13ed 100644 --- a/src/mesa/drivers/dri/intel/intel_blit.h +++ b/src/mesa/drivers/dri/intel/intel_blit.h @@ -29,7 +29,6 @@ #define INTEL_BLIT_H #include "intel_context.h" -#include "intel_ioctl.h" extern void intelCopyBuffer(const __DRIdrawablePrivate * dpriv, const drm_clip_rect_t * rect); diff --git a/src/mesa/drivers/dri/intel/intel_context.c b/src/mesa/drivers/dri/intel/intel_context.c index 591b521664..4d1a742698 100644 --- a/src/mesa/drivers/dri/intel/intel_context.c +++ b/src/mesa/drivers/dri/intel/intel_context.c @@ -51,7 +51,6 @@ #include "intel_chipset.h" #include "intel_buffers.h" #include "intel_tex.h" -#include "intel_ioctl.h" #include "intel_batchbuffer.h" #include "intel_blit.h" #include "intel_pixel.h" diff --git a/src/mesa/drivers/dri/intel/intel_ioctl.c b/src/mesa/drivers/dri/intel/intel_ioctl.c deleted file mode 100644 index c58a803505..0000000000 --- a/src/mesa/drivers/dri/intel/intel_ioctl.c +++ /dev/null @@ -1,128 +0,0 @@ -/************************************************************************** - * - * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas. - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sub license, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. - * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - **************************************************************************/ - - -#include -#include -#include -#include -#include -#include - -#include "mtypes.h" -#include "context.h" -#include "swrast/swrast.h" - -#include "intel_context.h" -#include "intel_ioctl.h" -#include "intel_batchbuffer.h" -#include "intel_blit.h" -#include "intel_regions.h" -#include "drm.h" -#include "i915_drm.h" - -#include "intel_bufmgr.h" - -#define FILE_DEBUG_FLAG DEBUG_IOCTL - -int -intel_batch_ioctl(struct intel_context *intel, - GLuint start_offset, - GLuint used, - GLboolean ignore_cliprects, GLboolean allow_unlock) -{ - struct drm_i915_batchbuffer batch; - - if (intel->no_hw) - return 0; - - assert(intel->locked); - assert(used); - - DBG("%s used %d offset %x..%x ignore_cliprects %d\n", - __FUNCTION__, - used, start_offset, start_offset + used, ignore_cliprects); - - /* Throw away non-effective packets. Won't work once we have - * hardware contexts which would preserve statechanges beyond a - * single buffer. - */ - batch.start = start_offset; - batch.used = used; - batch.cliprects = intel->pClipRects; - batch.num_cliprects = ignore_cliprects ? 0 : intel->numClipRects; - batch.DR1 = 0; - batch.DR4 = ((((GLuint) intel->drawX) & 0xffff) | - (((GLuint) intel->drawY) << 16)); - - DBG("%s: 0x%x..0x%x DR4: %x cliprects: %d\n", - __FUNCTION__, - batch.start, - batch.start + batch.used * 4, batch.DR4, batch.num_cliprects); - - if (drmCommandWrite(intel->driFd, DRM_I915_BATCHBUFFER, &batch, - sizeof(batch))) { - fprintf(stderr, "DRM_I915_BATCHBUFFER: %d\n", -errno); - return -errno; - } - - return 0; -} - -int -intel_exec_ioctl(struct intel_context *intel, - GLuint used, - GLboolean ignore_cliprects, GLboolean allow_unlock, - struct drm_i915_gem_execbuffer *execbuf) -{ - int ret; - - assert(intel->locked); - assert(used); - - if (intel->no_hw) - return 0; - - execbuf->batch_start_offset = 0; - execbuf->batch_len = used; - execbuf->cliprects_ptr = (uintptr_t)intel->pClipRects; - execbuf->num_cliprects = ignore_cliprects ? 0 : intel->numClipRects; - execbuf->DR1 = 0; - execbuf->DR4 = ((((GLuint) intel->drawX) & 0xffff) | - (((GLuint) intel->drawY) << 16)); - - do { - ret = ioctl(intel->driFd, DRM_IOCTL_I915_GEM_EXECBUFFER, execbuf); - } while (ret == -EAGAIN); - - if (ret != 0) { - fprintf(stderr, "DRM_I915_GEM_EXECBUFFER: %d\n", -errno); - return -errno; - } - - return 0; -} diff --git a/src/mesa/drivers/dri/intel/intel_ioctl.h b/src/mesa/drivers/dri/intel/intel_ioctl.h deleted file mode 100644 index 6736856dbd..0000000000 --- a/src/mesa/drivers/dri/intel/intel_ioctl.h +++ /dev/null @@ -1,43 +0,0 @@ -/************************************************************************** - * - * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas. - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sub license, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. - * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - **************************************************************************/ - -#ifndef INTEL_IOCTL_H -#define INTEL_IOCTL_H - -#include "intel_context.h" - -int intel_batch_ioctl(struct intel_context *intel, - GLuint start_offset, - GLuint used, - GLboolean ignore_cliprects, - GLboolean allow_unlock); -int intel_exec_ioctl(struct intel_context *intel, - GLuint used, - GLboolean ignore_cliprects, GLboolean allow_unlock, - struct drm_i915_gem_execbuffer *execbuf); - -#endif diff --git a/src/mesa/drivers/dri/intel/intel_pixel_bitmap.c b/src/mesa/drivers/dri/intel/intel_pixel_bitmap.c index 7e0d20e681..daa6d4be17 100644 --- a/src/mesa/drivers/dri/intel/intel_pixel_bitmap.c +++ b/src/mesa/drivers/dri/intel/intel_pixel_bitmap.c @@ -36,7 +36,6 @@ #include "intel_screen.h" #include "intel_context.h" -#include "intel_ioctl.h" #include "intel_batchbuffer.h" #include "intel_blit.h" #include "intel_regions.h" diff --git a/src/mesa/drivers/dri/intel/intel_pixel_copy.c b/src/mesa/drivers/dri/intel/intel_pixel_copy.c index 3093ccf7c6..1c72d6179d 100644 --- a/src/mesa/drivers/dri/intel/intel_pixel_copy.c +++ b/src/mesa/drivers/dri/intel/intel_pixel_copy.c @@ -35,7 +35,6 @@ #include "intel_screen.h" #include "intel_context.h" -#include "intel_ioctl.h" #include "intel_batchbuffer.h" #include "intel_buffers.h" #include "intel_blit.h" diff --git a/src/mesa/drivers/dri/intel/intel_pixel_draw.c b/src/mesa/drivers/dri/intel/intel_pixel_draw.c index 5675084da5..47460da9aa 100644 --- a/src/mesa/drivers/dri/intel/intel_pixel_draw.c +++ b/src/mesa/drivers/dri/intel/intel_pixel_draw.c @@ -35,7 +35,6 @@ #include "intel_screen.h" #include "intel_context.h" -#include "intel_ioctl.h" #include "intel_batchbuffer.h" #include "intel_blit.h" #include "intel_buffers.h" diff --git a/src/mesa/drivers/dri/intel/intel_screen.c b/src/mesa/drivers/dri/intel/intel_screen.c index 2355eafeca..1de1ac49ea 100644 --- a/src/mesa/drivers/dri/intel/intel_screen.c +++ b/src/mesa/drivers/dri/intel/intel_screen.c @@ -41,7 +41,6 @@ #include "intel_buffers.h" #include "intel_tex.h" #include "intel_span.h" -#include "intel_ioctl.h" #include "intel_fbo.h" #include "intel_chipset.h" diff --git a/src/mesa/drivers/dri/intel/intel_span.c b/src/mesa/drivers/dri/intel/intel_span.c index edede3a74b..0ea8576a02 100644 --- a/src/mesa/drivers/dri/intel/intel_span.c +++ b/src/mesa/drivers/dri/intel/intel_span.c @@ -34,7 +34,6 @@ #include "intel_screen.h" #include "intel_span.h" #include "intel_regions.h" -#include "intel_ioctl.h" #include "intel_tex.h" #include "swrast/swrast.h" diff --git a/src/mesa/drivers/dri/intel/intel_tex_image.c b/src/mesa/drivers/dri/intel/intel_tex_image.c index 187fcc7dcb..d1f540b0f1 100644 --- a/src/mesa/drivers/dri/intel/intel_tex_image.c +++ b/src/mesa/drivers/dri/intel/intel_tex_image.c @@ -21,7 +21,6 @@ #include "intel_buffer_objects.h" #include "intel_batchbuffer.h" #include "intel_tex.h" -#include "intel_ioctl.h" #include "intel_blit.h" #include "intel_fbo.h" -- cgit v1.2.3 From bc3b2a5d7a63c29602c35a4868942c20eb838338 Mon Sep 17 00:00:00 2001 From: Shane Blackett Date: Wed, 10 Sep 2008 08:22:45 -0600 Subject: Fixes for Mingw --- src/mesa/Makefile.mgw | 2 +- src/mesa/main/imports.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/mesa/Makefile.mgw b/src/mesa/Makefile.mgw index 6244ded876..886b344ec9 100644 --- a/src/mesa/Makefile.mgw +++ b/src/mesa/Makefile.mgw @@ -154,7 +154,7 @@ DRIVER_SOURCES = \ endif endif -SOURCES = $(CORE_SOURCES) $(X86_SOURCES) $(COMMON_DRIVER_SOURCES) $(DRIVER_SOURCES) +SOURCES = $(MESA_SOURCES) $(GLAPI_SOURCES) $(X86_SOURCES) $(DRIVER_SOURCES) OBJECTS = $(addsuffix .o,$(basename $(SOURCES))) diff --git a/src/mesa/main/imports.c b/src/mesa/main/imports.c index 1aebb25163..7f2fca7e1d 100644 --- a/src/mesa/main/imports.c +++ b/src/mesa/main/imports.c @@ -559,7 +559,7 @@ _mesa_pow(double x, double y) int _mesa_ffs(int i) { -#if (defined(_WIN32) && !defined(__MINGW32__) ) || defined(__IBMC__) || defined(__IBMCPP__) +#if (defined(_WIN32) ) || defined(__IBMC__) || defined(__IBMCPP__) register int bit = 0; if (i != 0) { if ((i & 0xffff) == 0) { -- cgit v1.2.3 From 4d42c5bebf8740ebfc15571d24b6c92f79e09263 Mon Sep 17 00:00:00 2001 From: Shane Blackett Date: Thu, 11 Sep 2008 08:35:27 -0600 Subject: added 24bpp support --- src/mesa/drivers/windows/gdi/wmesa.c | 227 +++++++++++++++++++++++++++++++++-- 1 file changed, 217 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/windows/gdi/wmesa.c b/src/mesa/drivers/windows/gdi/wmesa.c index 1c179eb3bb..9dafb74723 100644 --- a/src/mesa/drivers/windows/gdi/wmesa.c +++ b/src/mesa/drivers/windows/gdi/wmesa.c @@ -118,6 +118,7 @@ static void wmSetPixelFormat(WMesaFramebuffer pwfb, HDC hDC) /* Only 16 and 32 bit targets are supported now */ assert(pwfb->cColorBits == 0 || pwfb->cColorBits == 16 || + pwfb->cColorBits == 24 || pwfb->cColorBits == 32); switch(pwfb->cColorBits){ @@ -127,6 +128,7 @@ static void wmSetPixelFormat(WMesaFramebuffer pwfb, HDC hDC) case 16: pwfb->pixelformat = PF_5R6G5B; break; + case 24: case 32: pwfb->pixelformat = PF_8R8G8B; break; @@ -854,6 +856,195 @@ static void read_rgba_pixels_32(const GLcontext *ctx, } +/*********************************************************************/ + +/* DOUBLE BUFFER 24-bit */ + +#define WMSETPIXEL24(pwc, y, x, r, g, b) { \ +LPBYTE lpb = ((LPBYTE)((pwc)->pbPixels + (pwc)->ScanWidth * (y)) + (3 * x)); \ +lpb[0] = (b); \ +lpb[1] = (g); \ +lpb[2] = (r); } + +/* Write a horizontal span of RGBA color pixels with a boolean mask. */ +static void write_rgba_span_24(const GLcontext *ctx, + struct gl_renderbuffer *rb, + GLuint n, GLint x, GLint y, + const GLubyte rgba[][4], + const GLubyte mask[] ) +{ + WMesaContext pwc = wmesa_context(ctx); + WMesaFramebuffer pwfb = wmesa_framebuffer(ctx->DrawBuffer); + GLuint i; + LPBYTE lpb; + + (void) ctx; + + y=FLIP(y); + lpb = ((LPBYTE)(pwfb->pbPixels + pwfb->ScanWidth * y)) + (3 * x); + if (mask) { + for (i=0; iDrawBuffer); + GLuint i; + LPBYTE lpb; + + (void) ctx; + + y=FLIP(y); + lpb = ((LPBYTE)(pwfb->pbPixels + pwfb->ScanWidth * y)) + (3 * x); + if (mask) { + for (i=0; iDrawBuffer); + lpb = ((LPBYTE)(pwfb->pbPixels + pwfb->ScanWidth * y)) + (3 * x); + y=FLIP(y); + if (mask) { + for (i=0; iDrawBuffer); + for (i=0; iDrawBuffer); + for (i=0; iDrawBuffer); + + y = FLIP(y); + lpb = ((LPBYTE)(pwfb->pbPixels + pwfb->ScanWidth * y)) + (3 * x); + for (i=0; iDrawBuffer); + + for (i=0; ipbPixels + pwfb->ScanWidth * y2)) + (3 * x[i]); + rgba[i][RCOMP] = lpb[3*i+2]; + rgba[i][GCOMP] = lpb[3*i+1]; + rgba[i][BCOMP] = lpb[3*i]; + rgba[i][ACOMP] = 255; + } +} + + /*********************************************************************/ /* DOUBLE BUFFER 16-bit */ @@ -1077,7 +1268,7 @@ wmesa_renderbuffer_storage(GLcontext *ctx, * on if we're drawing to the front or back color buffer. */ void wmesa_set_renderbuffer_funcs(struct gl_renderbuffer *rb, int pixelformat, - int double_buffer) + BYTE cColorBits, int double_buffer) { if (double_buffer) { /* back buffer */ @@ -1097,16 +1288,32 @@ void wmesa_set_renderbuffer_funcs(struct gl_renderbuffer *rb, int pixelformat, rb->BlueBits = 5; break; case PF_8R8G8B: - rb->PutRow = write_rgba_span_32; - rb->PutRowRGB = write_rgb_span_32; - rb->PutMonoRow = write_mono_rgba_span_32; - rb->PutValues = write_rgba_pixels_32; - rb->PutMonoValues = write_mono_rgba_pixels_32; - rb->GetRow = read_rgba_span_32; - rb->GetValues = read_rgba_pixels_32; + if (cColorBits == 24) + { + rb->PutRow = write_rgba_span_24; + rb->PutRowRGB = write_rgb_span_24; + rb->PutMonoRow = write_mono_rgba_span_24; + rb->PutValues = write_rgba_pixels_24; + rb->PutMonoValues = write_mono_rgba_pixels_24; + rb->GetRow = read_rgba_span_24; + rb->GetValues = read_rgba_pixels_24; + rb->RedBits = 8; + rb->GreenBits = 8; + rb->BlueBits = 8; + } + else + { + rb->PutRow = write_rgba_span_32; + rb->PutRowRGB = write_rgb_span_32; + rb->PutMonoRow = write_mono_rgba_span_32; + rb->PutValues = write_rgba_pixels_32; + rb->PutMonoValues = write_mono_rgba_pixels_32; + rb->GetRow = read_rgba_span_32; + rb->GetValues = read_rgba_pixels_32; rb->RedBits = 8; rb->GreenBits = 8; rb->BlueBits = 8; + } break; default: break; @@ -1413,11 +1620,11 @@ void WMesaMakeCurrent(WMesaContext c, HDC hdc) if (visual->doubleBufferMode == 1) { rb = wmesa_new_renderbuffer(); _mesa_add_renderbuffer(&pwfb->Base, BUFFER_BACK_LEFT, rb); - wmesa_set_renderbuffer_funcs(rb, pwfb->pixelformat, 1); + wmesa_set_renderbuffer_funcs(rb, pwfb->pixelformat, pwfb->cColorBits, 1); } rb = wmesa_new_renderbuffer(); _mesa_add_renderbuffer(&pwfb->Base, BUFFER_FRONT_LEFT, rb); - wmesa_set_renderbuffer_funcs(rb, pwfb->pixelformat, 0); + wmesa_set_renderbuffer_funcs(rb, pwfb->pixelformat, pwfb->cColorBits, 0); /* Let Mesa own the Depth, Stencil, and Accum buffers */ _mesa_add_soft_renderbuffers(&pwfb->Base, -- cgit v1.2.3