From bdc5394d22d7bc1215c9a38f735a419c9063ab05 Mon Sep 17 00:00:00 2001 From: Zou Nan hai Date: Wed, 24 Jan 2007 15:47:15 +0800 Subject: 965 ARB_Occlusion_query fix --- src/mesa/drivers/dri/i965/intel_context.c | 27 ++++++++++++++++----------- src/mesa/drivers/dri/i965/intel_context.h | 2 +- src/mesa/drivers/dri/i965/intel_screen.c | 6 ++---- 3 files changed, 19 insertions(+), 16 deletions(-) (limited to 'src/mesa') diff --git a/src/mesa/drivers/dri/i965/intel_context.c b/src/mesa/drivers/dri/i965/intel_context.c index 459ed109ed5..388600dbbe5 100644 --- a/src/mesa/drivers/dri/i965/intel_context.c +++ b/src/mesa/drivers/dri/i965/intel_context.c @@ -184,9 +184,17 @@ const struct dri_extension card_extensions[] = { NULL, NULL } }; -static const struct dri_extension arb_oc_extension = +const struct dri_extension arb_oc_extension = { "GL_ARB_occlusion_query", GL_ARB_occlusion_query_functions}; +void intelInitExtensions(GLcontext *ctx, GLboolean enable_imaging) +{ + struct intel_context *intel = ctx?intel_context(ctx):NULL; + driInitExtensions(ctx, card_extensions, enable_imaging); + if (!ctx || intel->intelScreen->drmMinor >= 8) + driInitSingleExtension (ctx, &arb_oc_extension); +} + static const struct dri_debug_control debug_control[] = { { "fall", DEBUG_FALLBACKS }, @@ -248,28 +256,29 @@ static void intelBeginQuery(GLcontext *ctx, GLenum target, struct gl_query_object *q) { struct intel_context *intel = intel_context( ctx ); - GLuint64EXT tmp = 0; drmI830MMIO io = { .read_write = MMIO_WRITE, .reg = MMIO_REGS_PS_DEPTH_COUNT, - .data = &tmp + .data = &q->Result }; intel->stats_wm = GL_TRUE; intelFinish(&intel->ctx); - drmCommandWrite(intel->driFd, DRM_I830_MMIO, &io, sizeof(io)); + drmCommandRead(intel->driFd, DRM_I830_MMIO, &io, sizeof(io)); } static void intelEndQuery(GLcontext *ctx, GLenum target, struct gl_query_object *q) { struct intel_context *intel = intel_context( ctx ); + GLuint64EXT tmp; drmI830MMIO io = { .read_write = MMIO_READ, .reg = MMIO_REGS_PS_DEPTH_COUNT, - .data = &q->Result + .data = &tmp }; intelFinish(&intel->ctx); drmCommandRead(intel->driFd, DRM_I830_MMIO, &io, sizeof(io)); + q->Result = tmp - q->Result; q->Ready = GL_TRUE; intel->stats_wm = GL_FALSE; } @@ -409,12 +418,7 @@ GLboolean intelInitContext( struct intel_context *intel, _mesa_printf("IRQs not active. Exiting\n"); exit(1); } - - driInitExtensions( ctx, card_extensions, - GL_TRUE ); - - if (intel->intelScreen->drmMinor >= 8) - driInitSingleExtension (ctx, &arb_oc_extension); + intelInitExtensions(ctx, GL_TRUE); INTEL_DEBUG = driParseDebugString( getenv( "INTEL_DEBUG" ), debug_control ); @@ -693,3 +697,4 @@ void UNLOCK_HARDWARE( struct intel_context *intel ) _glthread_UNLOCK_MUTEX(lockMutex); } + diff --git a/src/mesa/drivers/dri/i965/intel_context.h b/src/mesa/drivers/dri/i965/intel_context.h index fe7ee382a19..d51536c3fe8 100644 --- a/src/mesa/drivers/dri/i965/intel_context.h +++ b/src/mesa/drivers/dri/i965/intel_context.h @@ -500,6 +500,7 @@ void intelBitmap(GLcontext * ctx, const struct gl_pixelstore_attrib *unpack, const GLubyte * pixels); +void intelInitExtensions(GLcontext *ctx, GLboolean enable_imaging); #define _NEW_WINDOW_POS 0x40000000 @@ -522,6 +523,5 @@ static inline struct intel_texture_image *intel_texture_image( struct gl_texture return (struct intel_texture_image *)img; } - #endif diff --git a/src/mesa/drivers/dri/i965/intel_screen.c b/src/mesa/drivers/dri/i965/intel_screen.c index 8269deba664..08f0bb340f7 100644 --- a/src/mesa/drivers/dri/i965/intel_screen.c +++ b/src/mesa/drivers/dri/i965/intel_screen.c @@ -38,6 +38,7 @@ #include "intel_screen.h" +#include "intel_context.h" #include "intel_tex.h" #include "intel_span.h" #include "intel_ioctl.h" @@ -61,8 +62,6 @@ const GLuint __driNConfigOptions = 4; static PFNGLXCREATECONTEXTMODES create_context_modes = NULL; #endif /*USE_NEW_INTERFACE*/ -extern const struct dri_extension card_extensions[]; - /** * Map all the memory regions described by the screen. * \return GL_TRUE if success, GL_FALSE if error. @@ -687,7 +686,6 @@ void * __driCreateNewScreen_20050727( __DRInativeDisplay *dpy, int scrn, __DRIsc (dri_priv->cpp == 2) ? 16 : 24, (dri_priv->cpp == 2) ? 0 : 8, GL_TRUE ); - /* Calling driInitExtensions here, with a NULL context pointer, does not actually * enable the extensions. It just makes sure that all the dispatch offsets for all * the extensions that *might* be enables are known. This is needed because the @@ -696,7 +694,7 @@ void * __driCreateNewScreen_20050727( __DRInativeDisplay *dpy, int scrn, __DRIsc * * Hello chicken. Hello egg. How are you two today? */ - driInitExtensions( NULL, card_extensions, GL_FALSE ); + intelInitExtensions(NULL, GL_FALSE); } return (void *) psp; -- cgit v1.2.3 From 844e5610de6ffe6966072d120b50db541ea85104 Mon Sep 17 00:00:00 2001 From: Zou Nan hai Date: Wed, 24 Jan 2007 16:07:43 +0800 Subject: 965 glxswapcontrol fix --- src/mesa/drivers/dri/i965/intel_context.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/mesa') diff --git a/src/mesa/drivers/dri/i965/intel_context.c b/src/mesa/drivers/dri/i965/intel_context.c index 388600dbbe5..f7ab7d3b7d5 100644 --- a/src/mesa/drivers/dri/i965/intel_context.c +++ b/src/mesa/drivers/dri/i965/intel_context.c @@ -61,6 +61,7 @@ #include "bufmgr.h" #include "utils.h" +#include "vblank.h" #ifndef INTEL_DEBUG int INTEL_DEBUG = (0); #endif @@ -336,6 +337,11 @@ GLboolean intelInitContext( struct intel_context *intel, intel->driScreen = sPriv; intel->sarea = saPriv; + driParseConfigFiles (&intel->optionCache, &intelScreen->optionCache, + intel->driScreen->myNum, "i965"); + + intel->vblank_flags = (intel->intelScreen->irq_active != 0) + ? driGetDefaultVBlankFlags(&intel->optionCache) : VBLANK_FLAG_NO_IRQ; ctx->Const.MaxTextureMaxAnisotropy = 2.0; @@ -563,6 +569,9 @@ GLboolean intelMakeCurrent(__DRIcontextPrivate *driContextPriv, if ( intel->driDrawable != driDrawPriv ) { /* Shouldn't the readbuffer be stored also? */ + driDrawableInitVBlank( driDrawPriv, intel->vblank_flags, + &intel->vbl_seq ); + intel->driDrawable = driDrawPriv; intelWindowMoved( intel ); } -- cgit v1.2.3 From 42bd32dad7f2bd9b4c4df8a7394328d31748f1f5 Mon Sep 17 00:00:00 2001 From: Ben Skeggs Date: Thu, 25 Jan 2007 11:56:45 +1100 Subject: nouveau: some extra debug output --- src/mesa/drivers/dri/nouveau/nouveau_screen.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/mesa') diff --git a/src/mesa/drivers/dri/nouveau/nouveau_screen.c b/src/mesa/drivers/dri/nouveau/nouveau_screen.c index 781ba0113fc..2d14a9d84d0 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_screen.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_screen.c @@ -339,8 +339,11 @@ void * __driCreateNewScreen_20050727( __DRInativeDisplay *dpy, int scrn, __DRIsc } // temporary lock step versioning - if (drm_expected.patch!=drm_version->patch) + if (drm_expected.patch!=drm_version->patch) { + __driUtilMessage("%s: wrong DRM version, expected %d, got %d\n", + drm_expected.patch, drm_version->patch); return NULL; + } psp = __driUtilCreateNewScreen(dpy, scrn, psc, NULL, ddx_version, dri_version, drm_version, -- cgit v1.2.3 From 2d7687865e8831e365756f1270c03ee70298ba4c Mon Sep 17 00:00:00 2001 From: Ben Skeggs Date: Thu, 25 Jan 2007 12:08:49 +1100 Subject: nouveau: and here's the "oops, I suck" commit :) --- src/mesa/drivers/dri/nouveau/nouveau_screen.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/mesa') diff --git a/src/mesa/drivers/dri/nouveau/nouveau_screen.c b/src/mesa/drivers/dri/nouveau/nouveau_screen.c index 2d14a9d84d0..881b20149f0 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_screen.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_screen.c @@ -341,6 +341,7 @@ void * __driCreateNewScreen_20050727( __DRInativeDisplay *dpy, int scrn, __DRIsc // temporary lock step versioning if (drm_expected.patch!=drm_version->patch) { __driUtilMessage("%s: wrong DRM version, expected %d, got %d\n", + __func__, drm_expected.patch, drm_version->patch); return NULL; } -- cgit v1.2.3 From 86996dfe32fccd5777dd0e410b5dbe964fb206d1 Mon Sep 17 00:00:00 2001 From: Ben Skeggs Date: Thu, 25 Jan 2007 13:40:51 +1100 Subject: nouveau: add result scaling to shader backend, use it in RSQ emul for NV40. --- src/mesa/drivers/dri/nouveau/nouveau_shader.c | 2 +- src/mesa/drivers/dri/nouveau/nouveau_shader.h | 13 ++++++++++++ src/mesa/drivers/dri/nouveau/nouveau_shader_0.c | 17 +++------------- src/mesa/drivers/dri/nouveau/nouveau_shader_2.c | 4 ++++ src/mesa/drivers/dri/nouveau/nv40_fragprog.c | 27 +++++++++++++++++++++++++ src/mesa/drivers/dri/nouveau/nv40_shader.h | 4 ++-- 6 files changed, 50 insertions(+), 17 deletions(-) (limited to 'src/mesa') diff --git a/src/mesa/drivers/dri/nouveau/nouveau_shader.c b/src/mesa/drivers/dri/nouveau/nouveau_shader.c index f911347d624..cdb79fca1e6 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_shader.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_shader.c @@ -179,7 +179,7 @@ nvsBuildTextShader(GLcontext *ctx, GLenum target, const char *text) strlen(text), &nvs->mesa.vp); } else if (target == GL_FRAGMENT_PROGRAM_ARB) { - _mesa_init_fragment_program(ctx, &nvs->mesa.fp, GL_VERTEX_PROGRAM_ARB, 0); + _mesa_init_fragment_program(ctx, &nvs->mesa.fp, GL_FRAGMENT_PROGRAM_ARB, 0); _mesa_parse_arb_fragment_program(ctx, GL_FRAGMENT_PROGRAM_ARB, text, diff --git a/src/mesa/drivers/dri/nouveau/nouveau_shader.h b/src/mesa/drivers/dri/nouveau/nouveau_shader.h index 8b4be9dfe7c..7329ccd9ead 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_shader.h +++ b/src/mesa/drivers/dri/nouveau/nouveau_shader.h @@ -194,6 +194,16 @@ typedef enum { NVS_TEX_TARGET_UNKNOWN = 0 } nvsTexTarget; +typedef enum { + NVS_SCALE_1X = 0, + NVS_SCALE_2X = 1, + NVS_SCALE_4X = 2, + NVS_SCALE_8X = 3, + NVS_SCALE_INV_2X = 5, + NVS_SCALE_INV_4X = 6, + NVS_SCALE_INV_8X = 7, +} nvsScale; + /* Arith/TEX instructions */ typedef struct nvs_instruction { nvsFragmentHeader header; @@ -203,6 +213,7 @@ typedef struct nvs_instruction { nvsRegister dest; unsigned int mask; + nvsScale dest_scale; nvsRegister src[3]; @@ -307,6 +318,7 @@ struct _nvsFunc { void (*InitInstruction) (nvsFunc *); int (*SupportsOpcode) (nvsFunc *, nvsOpcode); + int (*SupportsResultScale) (nvsFunc *, nvsScale); void (*SetOpcode) (nvsFunc *, unsigned int opcode, int slot); void (*SetCCUpdate) (nvsFunc *); @@ -314,6 +326,7 @@ struct _nvsFunc { nvsSwzComp *swizzle); void (*SetResult) (nvsFunc *, nvsRegister *, unsigned int mask, int slot); + void (*SetResultScale) (nvsFunc *, nvsScale); void (*SetSource) (nvsFunc *, nvsRegister *, int pos); void (*SetTexImageUnit) (nvsFunc *, int unit); void (*SetSaturate) (nvsFunc *); diff --git a/src/mesa/drivers/dri/nouveau/nouveau_shader_0.c b/src/mesa/drivers/dri/nouveau/nouveau_shader_0.c index 28c6ad803b1..3bcc2ba755c 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_shader_0.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_shader_0.c @@ -402,6 +402,7 @@ pass0_emit(nouveauShader *nvs, nvsFragmentHeader *parent, int fpos, sif->saturate = saturate; sif->dest = dst; sif->mask = mask; + sif->dest_scale = NVS_SCALE_1X; sif->src[0] = src0; sif->src[1] = src1; sif->src[2] = src2; @@ -667,25 +668,13 @@ pass0_emulate_instruction(nouveauShader *nvs, } break; case OPCODE_RSQ: - if (rec->const_half.file != NVS_FILE_CONST) { - GLfloat const_half[4] = { 0.5, 0.0, 0.0, 0.0 }; - pass0_make_reg(nvs, &rec->const_half, NVS_FILE_CONST, - _mesa_add_unnamed_constant( - nvs->mesa.vp.Base.Parameters, - const_half, 4)); - COPY_4V(nvs->params[rec->const_half.index].val, - const_half); - } pass0_make_reg(nvs, &temp, NVS_FILE_TEMP, -1); ARITHu(NVS_OP_LG2, temp, SMASK_X, 0, nvsAbs(nvsSwizzle(src[0], X, X, X, X)), nvr_unused, nvr_unused); - ARITHu(NVS_OP_MUL, temp, SMASK_X, 0, - nvsSwizzle(temp, X, X, X, X), - nvsNegate(rec->const_half), - nvr_unused); + nvsinst->dest_scale = NVS_SCALE_INV_2X; ARITH (NVS_OP_EX2, dest, mask, sat, - nvsSwizzle(temp, X, X, X, X), + nvsNegate(nvsSwizzle(temp, X, X, X, X)), nvr_unused, nvr_unused); break; case OPCODE_SCS: diff --git a/src/mesa/drivers/dri/nouveau/nouveau_shader_2.c b/src/mesa/drivers/dri/nouveau/nouveau_shader_2.c index c106fd2d949..b043f877e42 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_shader_2.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_shader_2.c @@ -135,6 +135,10 @@ pass2_add_instruction(nvsPtr nvs, nvsInstruction *inst, reg = pass2_mangle_reg(nvs, inst, inst->dest); shader->SetResult(shader, ®, inst->mask, slot); + + if (inst->dest_scale != NVS_SCALE_1X) { + shader->SetResultScale(shader, inst->dest_scale); + } } static int diff --git a/src/mesa/drivers/dri/nouveau/nv40_fragprog.c b/src/mesa/drivers/dri/nouveau/nv40_fragprog.c index 8bca6ae9383..3e4ae0496e4 100644 --- a/src/mesa/drivers/dri/nouveau/nv40_fragprog.c +++ b/src/mesa/drivers/dri/nouveau/nv40_fragprog.c @@ -11,6 +11,30 @@ struct _op_xlat NVFP_TX_BOP[64]; * - These extend the NV30 routines, which are almost identical. NV40 * just has branching hacked into the instruction set. */ +static int +NV40FPSupportsResultScale(nvsFunc *shader, nvsScale scale) +{ + switch (scale) { + case NVS_SCALE_1X: + case NVS_SCALE_2X: + case NVS_SCALE_4X: + case NVS_SCALE_8X: + case NVS_SCALE_INV_2X: + case NVS_SCALE_INV_4X: + case NVS_SCALE_INV_8X: + return 1; + default: + return 0; + } +} + +static void +NV40FPSetResultScale(nvsFunc *shader, nvsScale scale) +{ + shader->inst[2] &= ~NV40_FP_OP_DST_SCALE_MASK; + shader->inst[2] |= ((unsigned int)scale << NV40_FP_OP_DST_SCALE_SHIFT); +} + static void NV40FPSetBranchTarget(nvsFunc *shader, int addr) { @@ -179,6 +203,9 @@ NV40FPInitShaderFuncs(nvsFunc * shader) MOD_OPCODE(NVFP_TX_BOP, NV40_FP_OP_BRA_OPCODE_REP , NVS_OP_REP , -1, -1, -1); MOD_OPCODE(NVFP_TX_BOP, NV40_FP_OP_BRA_OPCODE_RET , NVS_OP_RET , -1, -1, -1); + shader->SupportsResultScale = NV40FPSupportsResultScale; + shader->SetResultScale = NV40FPSetResultScale; + /* fragment.facing */ shader->GetSourceID = NV40FPGetSourceID; diff --git a/src/mesa/drivers/dri/nouveau/nv40_shader.h b/src/mesa/drivers/dri/nouveau/nv40_shader.h index 2a2b5639b6c..584f4c23e08 100644 --- a/src/mesa/drivers/dri/nouveau/nv40_shader.h +++ b/src/mesa/drivers/dri/nouveau/nv40_shader.h @@ -399,8 +399,8 @@ /* high order bits of SRC1 */ #define NV40_FP_OP_OPCODE_IS_BRANCH (1<<31) -#define NV40_FP_OP_SRC_SCALE_SHIFT 28 -#define NV40_FP_OP_SRC_SCALE_MASK (3 << 28) +#define NV40_FP_OP_DST_SCALE_SHIFT 28 +#define NV40_FP_OP_DST_SCALE_MASK (3 << 28) /* SRC1 LOOP */ #define NV40_FP_OP_LOOP_INCR_SHIFT 19 -- cgit v1.2.3 From d5db167c2cf9243c3153efb29582df72d819e7ac Mon Sep 17 00:00:00 2001 From: Ben Skeggs Date: Thu, 25 Jan 2007 15:12:49 +1100 Subject: nouveau: unbreak NOUVEAU_RING_DEBUG --- src/mesa/drivers/dri/nouveau/nouveau_sync.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/mesa') diff --git a/src/mesa/drivers/dri/nouveau/nouveau_sync.c b/src/mesa/drivers/dri/nouveau/nouveau_sync.c index 0bf20e723bb..e7bc4fcd5ee 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_sync.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_sync.c @@ -14,6 +14,10 @@ nouveau_notifier_new(GLcontext *ctx, GLuint handle) nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx); nouveau_notifier *notifier; +#ifdef NOUVEAU_RING_DEBUG + return NULL; +#endif + notifier = CALLOC_STRUCT(nouveau_notifier_t); if (!notifier) return NULL; @@ -53,6 +57,10 @@ nouveau_notifier_reset(nouveau_notifier *notifier) { volatile GLuint *n = notifier->mem->map; +#ifdef NOUVEAU_RING_DEBUG + return; +#endif + n[NV_NOTIFY_TIME_0 /4] = 0x00000000; n[NV_NOTIFY_TIME_1 /4] = 0x00000000; n[NV_NOTIFY_RETURN_VALUE/4] = 0x00000000; @@ -67,6 +75,10 @@ nouveau_notifier_wait_status(nouveau_notifier *notifier, GLuint status, volatile GLuint *n = notifier->mem->map; unsigned int time = 0; +#ifdef NOUVEAU_RING_DEBUG + return GL_TRUE; +#endif + while (time <= timeout) { if (n[NV_NOTIFY_STATE/4] & NV_NOTIFY_STATE_ERROR_CODE_MASK) { MESSAGE("Notifier returned error: 0x%04x\n", @@ -114,6 +126,10 @@ GLboolean nouveauSyncInitFuncs(GLcontext *ctx) { nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx); +#ifdef NOUVEAU_RING_DEBUG + return GL_TRUE; +#endif + nmesa->syncNotifier = nouveau_notifier_new(ctx, NvSyncNotify); if (!nmesa->syncNotifier) { MESSAGE("Failed to create channel sync notifier\n"); -- cgit v1.2.3 From 6aa62ba43f64f617c608e52b63c7eaa7aae16fb4 Mon Sep 17 00:00:00 2001 From: Zou Nan hai Date: Fri, 26 Jan 2007 07:04:15 +0800 Subject: ARB_Occlusion_query should support multiple query at same time --- src/mesa/drivers/dri/i965/intel_context.c | 6 +++--- src/mesa/drivers/dri/i965/intel_context.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src/mesa') diff --git a/src/mesa/drivers/dri/i965/intel_context.c b/src/mesa/drivers/dri/i965/intel_context.c index f7ab7d3b7d5..3f8c2c0890c 100644 --- a/src/mesa/drivers/dri/i965/intel_context.c +++ b/src/mesa/drivers/dri/i965/intel_context.c @@ -258,11 +258,11 @@ intelBeginQuery(GLcontext *ctx, GLenum target, struct gl_query_object *q) { struct intel_context *intel = intel_context( ctx ); drmI830MMIO io = { - .read_write = MMIO_WRITE, + .read_write = MMIO_READ, .reg = MMIO_REGS_PS_DEPTH_COUNT, .data = &q->Result }; - intel->stats_wm = GL_TRUE; + intel->stats_wm++; intelFinish(&intel->ctx); drmCommandRead(intel->driFd, DRM_I830_MMIO, &io, sizeof(io)); } @@ -281,7 +281,7 @@ intelEndQuery(GLcontext *ctx, GLenum target, struct gl_query_object *q) drmCommandRead(intel->driFd, DRM_I830_MMIO, &io, sizeof(io)); q->Result = tmp - q->Result; q->Ready = GL_TRUE; - intel->stats_wm = GL_FALSE; + intel->stats_wm--; } diff --git a/src/mesa/drivers/dri/i965/intel_context.h b/src/mesa/drivers/dri/i965/intel_context.h index d51536c3fe8..a0f392f9353 100644 --- a/src/mesa/drivers/dri/i965/intel_context.h +++ b/src/mesa/drivers/dri/i965/intel_context.h @@ -177,7 +177,7 @@ struct intel_context GLuint second_last_swap_fence; GLboolean aub_wrap; - GLboolean stats_wm; + GLuint stats_wm; struct intel_batchbuffer *batch; -- cgit v1.2.3 From c9b33ecd7c07cace0a6553ccfdaf7b021959c934 Mon Sep 17 00:00:00 2001 From: George Sapountzis Date: Wed, 6 Dec 2006 06:43:23 +0200 Subject: Drop old (pre-AIGLX) GLcore interface. The old GLcore interface was replaced in Xorg 7.1 with the addition of AIGLX, it is only used by DDX's which are known not to work with the new DIX glx code. --- Bug 9285: misc glcore, xmesa cleanups ACKed by Ian Romanick. --- include/GL/internal/glcore.h | 257 +------------------------------------------ src/mesa/main/context.c | 7 +- src/mesa/main/imports.c | 13 +-- 3 files changed, 5 insertions(+), 272 deletions(-) (limited to 'src/mesa') diff --git a/include/GL/internal/glcore.h b/include/GL/internal/glcore.h index ca3cf5be572..3cb792f393a 100644 --- a/include/GL/internal/glcore.h +++ b/include/GL/internal/glcore.h @@ -189,259 +189,6 @@ typedef struct __GLcontextModesRec { /************************************************************************/ -/* -** Structure used for allocating and freeing drawable private memory. -** (like software buffers, for example). -** -** The memory allocation routines are provided by the surrounding -** "operating system" code, and they are to be used for allocating -** software buffers and things which are associated with the drawable, -** and used by any context which draws to that drawable. There are -** separate memory allocation functions for drawables and contexts -** since drawables and contexts can be created and destroyed independently -** of one another, and the "operating system" may want to use separate -** allocation arenas for each. -** -** The freePrivate function is filled in by the core routines when they -** allocates software buffers, and stick them in "private". The freePrivate -** function will destroy anything allocated to this drawable (to be called -** when the drawable is destroyed). -*/ -typedef struct __GLdrawableRegionRec __GLdrawableRegion; -typedef struct __GLdrawableBufferRec __GLdrawableBuffer; -typedef struct __GLdrawablePrivateRec __GLdrawablePrivate; - -typedef struct __GLregionRectRec { - /* lower left (inside the rectangle) */ - GLint x0, y0; - /* upper right (outside the rectangle) */ - GLint x1, y1; -} __GLregionRect; - -struct __GLdrawableRegionRec { - GLint numRects; - __GLregionRect *rects; - __GLregionRect boundingRect; -}; - -/************************************************************************/ - -/* masks for the buffers */ -#define __GL_FRONT_BUFFER_MASK 0x00000001 -#define __GL_FRONT_LEFT_BUFFER_MASK 0x00000001 -#define __GL_FRONT_RIGHT_BUFFER_MASK 0x00000002 -#define __GL_BACK_BUFFER_MASK 0x00000004 -#define __GL_BACK_LEFT_BUFFER_MASK 0x00000004 -#define __GL_BACK_RIGHT_BUFFER_MASK 0x00000008 -#define __GL_ACCUM_BUFFER_MASK 0x00000010 -#define __GL_DEPTH_BUFFER_MASK 0x00000020 -#define __GL_STENCIL_BUFFER_MASK 0x00000040 -#define __GL_AUX_BUFFER_MASK(i) (0x0000080 << (i)) - -#define __GL_ALL_BUFFER_MASK 0xffffffff - -/* what Resize routines return if resize resorted to fallback case */ -#define __GL_BUFFER_FALLBACK 0x10 - -typedef void (*__GLbufFallbackInitFn)(__GLdrawableBuffer *buf, - __GLdrawablePrivate *glPriv, GLint bits); -typedef void (*__GLbufMainInitFn)(__GLdrawableBuffer *buf, - __GLdrawablePrivate *glPriv, GLint bits, - __GLbufFallbackInitFn back); - -/* -** A drawable buffer -** -** This data structure describes the context side of a drawable. -** -** According to the spec there could be multiple contexts bound to the same -** drawable at the same time (from different threads). In order to avoid -** multiple-access conflicts, locks are used to serialize access. When a -** thread needs to access (read or write) a member of the drawable, it takes -** a lock first. Some of the entries in the drawable are treated "mostly -** constant", so we take the freedom of allowing access to them without -** taking a lock (for optimization reasons). -** -** For more details regarding locking, see buffers.h in the GL core -*/ -struct __GLdrawableBufferRec { - /* - ** Buffer dimensions - */ - GLint width, height, depth; - - /* - ** Framebuffer base address - */ - void *base; - - /* - ** Framebuffer size (in bytes) - */ - GLuint size; - - /* - ** Size (in bytes) of each element in the framebuffer - */ - GLuint elementSize; - GLuint elementSizeLog2; - - /* - ** Element skip from one scanline to the next. - ** If the buffer is part of another buffer (for example, fullscreen - ** front buffer), outerWidth is the width of that buffer. - */ - GLint outerWidth; - - /* - ** outerWidth * elementSize - */ - GLint byteWidth; - - /* - ** Allocation/deallocation is done based on this handle. A handle - ** is conceptually different from the framebuffer 'base'. - */ - void *handle; - - /* imported */ - GLboolean (*resize)(__GLdrawableBuffer *buf, - GLint x, GLint y, GLuint width, GLuint height, - __GLdrawablePrivate *glPriv, GLuint bufferMask); - void (*lock)(__GLdrawableBuffer *buf, __GLdrawablePrivate *glPriv); - void (*unlock)(__GLdrawableBuffer *buf, __GLdrawablePrivate *glPriv); - void (*fill)(__GLdrawableBuffer *buf, __GLdrawablePrivate *glPriv, - GLuint val, GLint x, GLint y, GLint w, GLint h); - void (*free)(__GLdrawableBuffer *buf, __GLdrawablePrivate *glPriv); - - /* exported */ - void (*freePrivate)(__GLdrawableBuffer *buf, __GLdrawablePrivate *glPriv); -#ifdef __cplusplus - void *privatePtr; -#else - void *private; -#endif - - /* private */ - void *other; /* implementation private data */ - __GLbufMainInitFn mainInit; - __GLbufFallbackInitFn fallbackInit; -}; - -/* -** The context side of the drawable private -*/ -struct __GLdrawablePrivateRec { - /* - ** Drawable Modes - */ - __GLcontextModes *modes; - - /* - ** Drawable size - */ - GLuint width, height; - - /* - ** Origin in screen coordinates of the drawable - */ - GLint xOrigin, yOrigin; -#ifdef __GL_ALIGNED_BUFFERS - /* - ** Drawable offset from screen origin - */ - GLint xOffset, yOffset; - - /* - ** Alignment restriction - */ - GLint xAlignment, yAlignment; -#endif - /* - ** Should we invert the y axis? - */ - GLint yInverted; - - /* - ** Mask specifying which buffers are renderable by the hw - */ - GLuint accelBufferMask; - - /* - ** the buffers themselves - */ - __GLdrawableBuffer frontBuffer; - __GLdrawableBuffer backBuffer; - __GLdrawableBuffer accumBuffer; - __GLdrawableBuffer depthBuffer; - __GLdrawableBuffer stencilBuffer; -#if defined(__GL_NUMBER_OF_AUX_BUFFERS) && (__GL_NUMBER_OF_AUX_BUFFERS > 0) - __GLdrawableBuffer *auxBuffer; -#endif - - __GLdrawableRegion ownershipRegion; - - /* - ** Lock for the drawable private structure - */ - void *lock; -#ifdef DEBUG - /* lock debugging info */ - int lockRefCount; - int lockLine[10]; - char *lockFile[10]; -#endif - - /* imported */ - void *(*malloc)(size_t size); - void *(*calloc)(size_t numElem, size_t elemSize); - void *(*realloc)(void *oldAddr, size_t newSize); - void (*free)(void *addr); - - GLboolean (*addSwapRect)(__GLdrawablePrivate *glPriv, - GLint x, GLint y, GLsizei width, GLsizei height); - void (*setClipRect)(__GLdrawablePrivate *glPriv, - GLint x, GLint y, GLsizei width, GLsizei height); - void (*updateClipRegion)(__GLdrawablePrivate *glPriv); - GLboolean (*resize)(__GLdrawablePrivate *glPriv); - void (*getDrawableSize)(__GLdrawablePrivate *glPriv, - GLint *x, GLint *y, GLuint *width, GLuint *height); - - void (*lockDP)(__GLdrawablePrivate *glPriv, __GLcontext *gc); - void (*unlockDP)(__GLdrawablePrivate *glPriv); - - /* exported */ -#ifdef __cplusplus - void *privatePtr; -#else - void *private; -#endif - void (*freePrivate)(__GLdrawablePrivate *); - - /* client data */ - void *other; -}; - -/* -** Macros to lock/unlock the drawable private -*/ -#if defined(DEBUG) -#define __GL_LOCK_DP(glPriv,gc) \ - (*(glPriv)->lockDP)(glPriv,gc); \ - (glPriv)->lockLine[(glPriv)->lockRefCount] = __LINE__; \ - (glPriv)->lockFile[(glPriv)->lockRefCount] = __FILE__; \ - (glPriv)->lockRefCount++ -#define __GL_UNLOCK_DP(glPriv) \ - (glPriv)->lockRefCount--; \ - (glPriv)->lockLine[(glPriv)->lockRefCount] = 0; \ - (glPriv)->lockFile[(glPriv)->lockRefCount] = NULL; \ - (*(glPriv)->unlockDP)(glPriv) -#else /* DEBUG */ -#define __GL_LOCK_DP(glPriv,gc) (*(glPriv)->lockDP)(glPriv,gc) -#define __GL_UNLOCK_DP(glPriv) (*(glPriv)->unlockDP)(glPriv) -#endif /* DEBUG */ - - /* ** Procedures which are imported by the GL from the surrounding ** "operating system". Math functions are not considered part of the @@ -467,8 +214,8 @@ typedef struct __GLimportsRec { int (CAPI *fprintf)(__GLcontext *gc, void *stream, const char *fmt, ...); /* Drawing surface management */ - __GLdrawablePrivate *(*getDrawablePrivate)(__GLcontext *gc); - __GLdrawablePrivate *(*getReadablePrivate)(__GLcontext *gc); + void *(*getDrawablePrivate)(__GLcontext *gc); + void *(*getReadablePrivate)(__GLcontext *gc); /* Operating system dependent data goes here */ void *other; diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c index 7ff45cffe8b..b2bd1d8a8e9 100644 --- a/src/mesa/main/context.c +++ b/src/mesa/main/context.c @@ -292,13 +292,8 @@ _mesa_forceCurrent(__GLcontext *gc) GLboolean _mesa_notifyResize(__GLcontext *gc) { - GLint x, y; - GLuint width, height; - __GLdrawablePrivate *d = gc->imports.getDrawablePrivate(gc); - if (!d || !d->getDrawableSize) - return GL_FALSE; - d->getDrawableSize( d, &x, &y, &width, &height ); /* update viewport, resize software buffers, etc. */ + (void) gc; return GL_TRUE; } diff --git a/src/mesa/main/imports.c b/src/mesa/main/imports.c index ed809acbe2a..996839a20e9 100644 --- a/src/mesa/main/imports.c +++ b/src/mesa/main/imports.c @@ -1176,16 +1176,6 @@ default_fprintf(__GLcontext *gc, void *stream, const char *fmt, ...) return r; } -/** - * \todo this really is driver-specific and can't be here - */ -static __GLdrawablePrivate * -default_GetDrawablePrivate(__GLcontext *gc) -{ - (void) gc; - return NULL; -} - /*@}*/ @@ -1222,6 +1212,7 @@ _mesa_init_default_imports(__GLimports *imports, void *driverCtx) imports->fopen = default_fopen; imports->fclose = default_fclose; imports->fprintf = default_fprintf; - imports->getDrawablePrivate = default_GetDrawablePrivate; + imports->getDrawablePrivate = NULL; /* driver-specific */ + imports->getReadablePrivate = NULL; /* driver-specific */ imports->other = driverCtx; } -- cgit v1.2.3 From 507167d7e2cf3bc64d1c112d927efeb1baa3b495 Mon Sep 17 00:00:00 2001 From: George Sapountzis Date: Wed, 6 Dec 2006 06:54:13 +0200 Subject: Override Const.CheckArrayBounds for Xserver in XMesaCreateContext(). This leaves one last XFree86Server ifdef in Mesa core. --- Bug 9285: misc glcore, xmesa cleanups ACKed by Ian Romanick. --- src/mesa/drivers/x11/xm_api.c | 7 +++++++ src/mesa/main/context.c | 8 +------- 2 files changed, 8 insertions(+), 7 deletions(-) (limited to 'src/mesa') diff --git a/src/mesa/drivers/x11/xm_api.c b/src/mesa/drivers/x11/xm_api.c index b50c4757afc..510fbd5849b 100644 --- a/src/mesa/drivers/x11/xm_api.c +++ b/src/mesa/drivers/x11/xm_api.c @@ -1545,6 +1545,13 @@ XMesaContext XMesaCreateContext( XMesaVisual v, XMesaContext share_list ) _mesa_enable_extension(mesaCtx, "GL_EXT_timer_query"); #endif +#ifdef XFree86Server + /* If we're running in the X server, do bounds checking to prevent + * segfaults and server crashes! + */ + mesaCtx->Const.CheckArrayBounds = GL_TRUE; +#endif + /* finish up xmesa context initializations */ c->swapbytes = CHECK_BYTE_ORDER(v) ? GL_FALSE : GL_TRUE; c->xm_visual = v; diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c index b2bd1d8a8e9..99f4dc9dfd4 100644 --- a/src/mesa/main/context.c +++ b/src/mesa/main/context.c @@ -1078,14 +1078,8 @@ _mesa_init_constants( GLcontext *ctx ) ctx->Const.MaxProgramMatrices = MAX_PROGRAM_MATRICES; ctx->Const.MaxProgramMatrixStackDepth = MAX_PROGRAM_MATRIX_STACK_DEPTH; - /* If we're running in the X server, do bounds checking to prevent - * segfaults and server crashes! - */ -#if defined(XFree86Server) - ctx->Const.CheckArrayBounds = GL_TRUE; -#else + /* CheckArrayBounds is overriden by drivers/x11 for X server */ ctx->Const.CheckArrayBounds = GL_FALSE; -#endif /* GL_ARB_draw_buffers */ ctx->Const.MaxDrawBuffers = MAX_DRAW_BUFFERS; -- cgit v1.2.3 From dbb54b234cd919b8ef7e36e0603ec69f3ed3fc7f Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Sat, 20 Jan 2007 17:59:08 -0800 Subject: Remove dead code causing a warning. --- src/mesa/drivers/dri/i965/intel_context.c | 5 ----- 1 file changed, 5 deletions(-) (limited to 'src/mesa') diff --git a/src/mesa/drivers/dri/i965/intel_context.c b/src/mesa/drivers/dri/i965/intel_context.c index 3f8c2c0890c..63809e0aa89 100644 --- a/src/mesa/drivers/dri/i965/intel_context.c +++ b/src/mesa/drivers/dri/i965/intel_context.c @@ -87,11 +87,6 @@ int INTEL_DEBUG = (0); int VERBOSE = 0; #endif -#if DEBUG_LOCKING -char *prevLockFile; -int prevLockLine; -#endif - /*************************************** * Mesa's Driver Functions ***************************************/ -- cgit v1.2.3 From 869b8ad499717eda4a1be04de4e516134123402c Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Sat, 20 Jan 2007 18:06:38 -0800 Subject: Add _mesa_ffsll() for compatibility on OSes without ffsll(), and use it. --- src/mesa/drivers/dri/i965/brw_draw_upload.c | 2 +- src/mesa/main/imports.c | 21 +++++++++++++++++++++ src/mesa/main/imports.h | 3 +++ 3 files changed, 25 insertions(+), 1 deletion(-) (limited to 'src/mesa') diff --git a/src/mesa/drivers/dri/i965/brw_draw_upload.c b/src/mesa/drivers/dri/i965/brw_draw_upload.c index 57ee294f0cf..08741ad90f6 100644 --- a/src/mesa/drivers/dri/i965/brw_draw_upload.c +++ b/src/mesa/drivers/dri/i965/brw_draw_upload.c @@ -414,7 +414,7 @@ GLboolean brw_upload_vertices( struct brw_context *brw, */ while (tmp) { - GLuint i = ffsll(tmp)-1; + GLuint i = _mesa_ffsll(tmp)-1; struct brw_vertex_element *input = &brw->vb.inputs[i]; tmp &= ~((GLuint64EXT)1<> 32); + if (bit != 0) + return 32 + bit; + + return 0; +#endif +} /** * Return number of bits set in given GLuint. diff --git a/src/mesa/main/imports.h b/src/mesa/main/imports.h index 19a9478f76a..d9885dbeec4 100644 --- a/src/mesa/main/imports.h +++ b/src/mesa/main/imports.h @@ -688,6 +688,9 @@ _mesa_pow(double x, double y); extern int _mesa_ffs(int i); +extern int +_mesa_ffsll(long long i); + extern unsigned int _mesa_bitcount(unsigned int n); -- cgit v1.2.3 From 5a3d9853958993174f13c8cff6bcf11993a48f65 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Sat, 20 Jan 2007 18:09:32 -0800 Subject: Bug #9604: Fix a static buffer allocation failure. The pool that the static buffer got allocated from was sized by pitch * height, but the buffer generated from it had its size aligned to a tile boundary, so allocation failed if pitch * height wasn't aligned. However, the 2d driver ensures that the size ends at a tile boundary, so just pass the 2d driver's buffer size rather than calculating it. --- src/mesa/drivers/dri/i965/intel_context.c | 6 ++++-- src/mesa/drivers/dri/i965/intel_regions.c | 2 +- src/mesa/drivers/dri/i965/intel_regions.h | 1 + 3 files changed, 6 insertions(+), 3 deletions(-) (limited to 'src/mesa') diff --git a/src/mesa/drivers/dri/i965/intel_context.c b/src/mesa/drivers/dri/i965/intel_context.c index 63809e0aa89..4486a28adc7 100644 --- a/src/mesa/drivers/dri/i965/intel_context.c +++ b/src/mesa/drivers/dri/i965/intel_context.c @@ -446,8 +446,8 @@ GLboolean intelInitContext( struct intel_context *intel, intelScreen->cpp, intelScreen->front.pitch / intelScreen->cpp, intelScreen->height, - intelScreen->front.tiled != 0); /* 0: LINEAR */ - + intelScreen->front.size, + intelScreen->front.tiled != 0); intel->back_region = intel_region_create_static(intel, @@ -457,6 +457,7 @@ GLboolean intelInitContext( struct intel_context *intel, intelScreen->cpp, intelScreen->back.pitch / intelScreen->cpp, intelScreen->height, + intelScreen->back.size, intelScreen->back.tiled != 0); /* Still assuming front.cpp == depth.cpp @@ -473,6 +474,7 @@ GLboolean intelInitContext( struct intel_context *intel, intelScreen->cpp, intelScreen->depth.pitch / intelScreen->cpp, intelScreen->height, + intelScreen->depth.size, intelScreen->depth.tiled != 0); intel_bufferobj_init( intel ); diff --git a/src/mesa/drivers/dri/i965/intel_regions.c b/src/mesa/drivers/dri/i965/intel_regions.c index 398b0a0a3b5..835ecdd7257 100644 --- a/src/mesa/drivers/dri/i965/intel_regions.c +++ b/src/mesa/drivers/dri/i965/intel_regions.c @@ -122,10 +122,10 @@ struct intel_region *intel_region_create_static( struct intel_context *intel, GLuint cpp, GLuint pitch, GLuint height, + GLuint size, GLboolean tiled ) { struct intel_region *region = calloc(sizeof(*region), 1); - GLuint size = cpp * pitch * height; GLint pool; DBG("%s\n", __FUNCTION__); diff --git a/src/mesa/drivers/dri/i965/intel_regions.h b/src/mesa/drivers/dri/i965/intel_regions.h index 2413f0de33c..d2235f1275b 100644 --- a/src/mesa/drivers/dri/i965/intel_regions.h +++ b/src/mesa/drivers/dri/i965/intel_regions.h @@ -78,6 +78,7 @@ struct intel_region *intel_region_create_static( struct intel_context *intel, GLuint cpp, GLuint pitch, GLuint height, + GLuint size, GLboolean tiled ); /* Map/unmap regions. This is refcounted also: -- cgit v1.2.3