From 88501887e48d1619e4296afa609dfe9904b81a70 Mon Sep 17 00:00:00 2001 From: Alan Swanson Date: Mon, 12 Mar 2007 09:59:28 +0100 Subject: radeon: Adapt cliprect fixes from r300. --- src/mesa/drivers/dri/radeon/radeon_context.c | 10 ++++++---- src/mesa/drivers/dri/radeon/radeon_lock.c | 1 - src/mesa/drivers/dri/radeon/radeon_state.c | 2 ++ 3 files changed, 8 insertions(+), 5 deletions(-) (limited to 'src/mesa') diff --git a/src/mesa/drivers/dri/radeon/radeon_context.c b/src/mesa/drivers/dri/radeon/radeon_context.c index 6bc2c4aa5c5..0d25951b648 100644 --- a/src/mesa/drivers/dri/radeon/radeon_context.c +++ b/src/mesa/drivers/dri/radeon/radeon_context.c @@ -594,12 +594,14 @@ radeonMakeCurrent( __DRIcontextPrivate *driContextPriv, driDrawableInitVBlank( driDrawPriv, newCtx->vblank_flags, &newCtx->vbl_seq ); } - - if ( (newCtx->dri.drawable != driDrawPriv) - || (newCtx->dri.readable != driReadPriv) ) { + + newCtx->dri.readable = driReadPriv; + + if ( (newCtx->dri.drawable != driDrawPriv) || + newCtx->lastStamp != driDrawPriv->lastStamp ) { newCtx->dri.drawable = driDrawPriv; - newCtx->dri.readable = driReadPriv; + radeonSetCliprects(newCtx); radeonUpdateWindow( newCtx->glCtx ); radeonUpdateViewportOffset( newCtx->glCtx ); } diff --git a/src/mesa/drivers/dri/radeon/radeon_lock.c b/src/mesa/drivers/dri/radeon/radeon_lock.c index e6ab6af4562..cdf8a19fb13 100644 --- a/src/mesa/drivers/dri/radeon/radeon_lock.c +++ b/src/mesa/drivers/dri/radeon/radeon_lock.c @@ -96,7 +96,6 @@ void radeonGetLock( radeonContextPtr rmesa, GLuint flags ) radeonSetCliprects( rmesa ); radeonUpdateViewportOffset( rmesa->glCtx ); driUpdateFramebufferSize(rmesa->glCtx, drawable); - rmesa->lastStamp = drawable->lastStamp; } RADEON_STATECHANGE( rmesa, ctx ); diff --git a/src/mesa/drivers/dri/radeon/radeon_state.c b/src/mesa/drivers/dri/radeon/radeon_state.c index e19202fa443..4de05c7697d 100644 --- a/src/mesa/drivers/dri/radeon/radeon_state.c +++ b/src/mesa/drivers/dri/radeon/radeon_state.c @@ -1675,6 +1675,8 @@ void radeonSetCliprects( radeonContextPtr rmesa ) if (rmesa->state.scissor.enabled) radeonRecalcScissorRects( rmesa ); + + rmesa->lastStamp = drawable->lastStamp; } -- cgit v1.2.3 From 33ea9dccaf31c2dfb0961847eedfe75336d9c80f Mon Sep 17 00:00:00 2001 From: Alan Swanson Date: Mon, 12 Mar 2007 09:59:45 +0100 Subject: r200: Adapt cliprect fixes from r300. --- src/mesa/drivers/dri/r200/r200_context.c | 6 ++++-- src/mesa/drivers/dri/r200/r200_lock.c | 1 - src/mesa/drivers/dri/r200/r200_state.c | 2 ++ 3 files changed, 6 insertions(+), 3 deletions(-) (limited to 'src/mesa') diff --git a/src/mesa/drivers/dri/r200/r200_context.c b/src/mesa/drivers/dri/r200/r200_context.c index fc6eb93daa8..75efd9a8382 100644 --- a/src/mesa/drivers/dri/r200/r200_context.c +++ b/src/mesa/drivers/dri/r200/r200_context.c @@ -673,11 +673,13 @@ r200MakeCurrent( __DRIcontextPrivate *driContextPriv, &newCtx->vbl_seq ); } + newCtx->dri.readable = driReadPriv; + if ( newCtx->dri.drawable != driDrawPriv || - newCtx->dri.readable != driReadPriv ) { + newCtx->lastStamp != driDrawPriv->lastStamp ) { newCtx->dri.drawable = driDrawPriv; - newCtx->dri.readable = driReadPriv; + r200SetCliprects(newCtx, GL_BACK_LEFT); r200UpdateWindow( newCtx->glCtx ); r200UpdateViewportOffset( newCtx->glCtx ); } diff --git a/src/mesa/drivers/dri/r200/r200_lock.c b/src/mesa/drivers/dri/r200/r200_lock.c index bcc0c916396..745e5964674 100644 --- a/src/mesa/drivers/dri/r200/r200_lock.c +++ b/src/mesa/drivers/dri/r200/r200_lock.c @@ -98,7 +98,6 @@ void r200GetLock( r200ContextPtr rmesa, GLuint flags ) r200SetCliprects( rmesa, GL_FRONT_LEFT ); r200UpdateViewportOffset( rmesa->glCtx ); driUpdateFramebufferSize(rmesa->glCtx, drawable); - rmesa->lastStamp = drawable->lastStamp; } R200_STATECHANGE( rmesa, ctx ); diff --git a/src/mesa/drivers/dri/r200/r200_state.c b/src/mesa/drivers/dri/r200/r200_state.c index bdb487f2b93..911a340f60b 100644 --- a/src/mesa/drivers/dri/r200/r200_state.c +++ b/src/mesa/drivers/dri/r200/r200_state.c @@ -1889,6 +1889,8 @@ void r200SetCliprects( r200ContextPtr rmesa, GLenum mode ) if (rmesa->state.scissor.enabled) r200RecalcScissorRects( rmesa ); + + rmesa->lastStamp = drawable->lastStamp; } -- cgit v1.2.3 From d0a3400f66b8c4ace7ebef6d0a944376d5203756 Mon Sep 17 00:00:00 2001 From: Alan Swanson Date: Mon, 12 Mar 2007 10:03:01 +0100 Subject: r200: Simplify r200SetCliprects like radeonSetCliprects in radeon and r300. --- src/mesa/drivers/dri/r200/r200_context.c | 2 +- src/mesa/drivers/dri/r200/r200_lock.c | 5 +---- src/mesa/drivers/dri/r200/r200_state.c | 35 +++++++++++++++++--------------- src/mesa/drivers/dri/r200/r200_state.h | 2 +- 4 files changed, 22 insertions(+), 22 deletions(-) (limited to 'src/mesa') diff --git a/src/mesa/drivers/dri/r200/r200_context.c b/src/mesa/drivers/dri/r200/r200_context.c index 75efd9a8382..3abcdf9e183 100644 --- a/src/mesa/drivers/dri/r200/r200_context.c +++ b/src/mesa/drivers/dri/r200/r200_context.c @@ -679,7 +679,7 @@ r200MakeCurrent( __DRIcontextPrivate *driContextPriv, newCtx->lastStamp != driDrawPriv->lastStamp ) { newCtx->dri.drawable = driDrawPriv; - r200SetCliprects(newCtx, GL_BACK_LEFT); + r200SetCliprects(newCtx); r200UpdateWindow( newCtx->glCtx ); r200UpdateViewportOffset( newCtx->glCtx ); } diff --git a/src/mesa/drivers/dri/r200/r200_lock.c b/src/mesa/drivers/dri/r200/r200_lock.c index 745e5964674..9ffdb2b2127 100644 --- a/src/mesa/drivers/dri/r200/r200_lock.c +++ b/src/mesa/drivers/dri/r200/r200_lock.c @@ -92,10 +92,7 @@ void r200GetLock( r200ContextPtr rmesa, GLuint flags ) if ( rmesa->lastStamp != drawable->lastStamp ) { r200UpdatePageFlipping( rmesa ); - if (rmesa->glCtx->DrawBuffer->_ColorDrawBufferMask[0] == BUFFER_BIT_BACK_LEFT) - r200SetCliprects( rmesa, GL_BACK_LEFT ); - else - r200SetCliprects( rmesa, GL_FRONT_LEFT ); + r200SetCliprects( rmesa ); r200UpdateViewportOffset( rmesa->glCtx ); driUpdateFramebufferSize(rmesa->glCtx, drawable); } diff --git a/src/mesa/drivers/dri/r200/r200_state.c b/src/mesa/drivers/dri/r200/r200_state.c index 911a340f60b..16726d7d55a 100644 --- a/src/mesa/drivers/dri/r200/r200_state.c +++ b/src/mesa/drivers/dri/r200/r200_state.c @@ -1691,6 +1691,11 @@ static void r200ClearStencil( GLcontext *ctx, GLint s ) #define SUBPIXEL_X 0.125 #define SUBPIXEL_Y 0.125 + +/** + * Called when window size or position changes or viewport or depth range + * state is changed. We update the hardware viewport state here. + */ void r200UpdateWindow( GLcontext *ctx ) { r200ContextPtr rmesa = R200_CONTEXT(ctx); @@ -1843,19 +1848,18 @@ static void r200LogicOpCode( GLcontext *ctx, GLenum opcode ) } -void r200SetCliprects( r200ContextPtr rmesa, GLenum mode ) +/* + * Set up the cliprects for either front or back-buffer drawing. + */ +void r200SetCliprects( r200ContextPtr rmesa ) { __DRIdrawablePrivate *const drawable = rmesa->dri.drawable; __DRIdrawablePrivate *const readable = rmesa->dri.readable; GLframebuffer *const draw_fb = (GLframebuffer*) drawable->driverPrivate; GLframebuffer *const read_fb = (GLframebuffer*) readable->driverPrivate; - switch ( mode ) { - case GL_FRONT_LEFT: - rmesa->numClipRects = drawable->numClipRects; - rmesa->pClipRects = drawable->pClipRects; - break; - case GL_BACK_LEFT: + if (draw_fb->_ColorDrawBufferMask[0] + == BUFFER_BIT_BACK_LEFT) { /* Can't ignore 2d windows if we are page flipping. */ if ( drawable->numBackClipRects == 0 || rmesa->doPageFlip ) { @@ -1866,11 +1870,12 @@ void r200SetCliprects( r200ContextPtr rmesa, GLenum mode ) rmesa->numClipRects = drawable->numBackClipRects; rmesa->pClipRects = drawable->pBackClipRects; } - break; - default: - fprintf(stderr, "bad mode in r200SetCliprects\n"); - return; } + else { + /* front buffer (or none, or multiple buffers) */ + rmesa->numClipRects = drawable->numClipRects; + rmesa->pClipRects = drawable->pClipRects; + } if ((draw_fb->Width != drawable->w) || (draw_fb->Height != drawable->h)) { _mesa_resize_framebuffer(rmesa->glCtx, draw_fb, @@ -1910,19 +1915,17 @@ static void r200DrawBuffer( GLcontext *ctx, GLenum mode ) */ switch ( ctx->DrawBuffer->_ColorDrawBufferMask[0] ) { case BUFFER_BIT_FRONT_LEFT: - FALLBACK( rmesa, R200_FALLBACK_DRAW_BUFFER, GL_FALSE ); - r200SetCliprects( rmesa, GL_FRONT_LEFT ); - break; case BUFFER_BIT_BACK_LEFT: FALLBACK( rmesa, R200_FALLBACK_DRAW_BUFFER, GL_FALSE ); - r200SetCliprects( rmesa, GL_BACK_LEFT ); break; default: - /* GL_NONE or GL_FRONT_AND_BACK or stereo left&right, etc */ + /* 0 (GL_NONE) buffers or multiple color drawing buffers */ FALLBACK( rmesa, R200_FALLBACK_DRAW_BUFFER, GL_TRUE ); return; } + r200SetCliprects( rmesa ); + /* We'll set the drawing engine's offset/pitch parameters later * when we update other state. */ diff --git a/src/mesa/drivers/dri/r200/r200_state.h b/src/mesa/drivers/dri/r200/r200_state.h index 98c6fbe40bb..f34090b619b 100644 --- a/src/mesa/drivers/dri/r200/r200_state.h +++ b/src/mesa/drivers/dri/r200/r200_state.h @@ -44,7 +44,7 @@ extern void r200InitTnlFuncs( GLcontext *ctx ); extern void r200UpdateMaterial( GLcontext *ctx ); -extern void r200SetCliprects( r200ContextPtr rmesa, GLenum mode ); +extern void r200SetCliprects( r200ContextPtr rmesa ); extern void r200RecalcScissorRects( r200ContextPtr rmesa ); extern void r200UpdateViewportOffset( GLcontext *ctx ); extern void r200UpdateWindow( GLcontext *ctx ); -- cgit v1.2.3 From c1a544733749cd388b9f51d087c695b2ce0ec729 Mon Sep 17 00:00:00 2001 From: Brian Date: Mon, 12 Mar 2007 09:35:44 -0600 Subject: take GL_UNPACK_ALIGNMENT into account in _mesa_image_row_stride() for GL_BITMAP type (bug 10261) --- src/mesa/main/image.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/mesa') diff --git a/src/mesa/main/image.c b/src/mesa/main/image.c index eb91ebb6110..58dd771484c 100644 --- a/src/mesa/main/image.c +++ b/src/mesa/main/image.c @@ -667,7 +667,7 @@ _mesa_image_row_stride( const struct gl_pixelstore_attrib *packing, ASSERT(packing); if (type == GL_BITMAP) { /* BITMAP data */ - GLint bytes; + GLint bytes, remainder; if (packing->RowLength == 0) { bytes = (width + 7) / 8; } @@ -678,6 +678,11 @@ _mesa_image_row_stride( const struct gl_pixelstore_attrib *packing, /* negate the bytes per row (negative row stride) */ bytes = -bytes; } + + remainder = bytes % packing->Alignment; + if (remainder > 0) + bytes += (packing->Alignment - remainder); + return bytes; } else { -- cgit v1.2.3 From 17fb7821d7cdc0ed211eaef013ee7798619a61d3 Mon Sep 17 00:00:00 2001 From: Brian Date: Mon, 12 Mar 2007 09:49:44 -0600 Subject: clean-up, simplify _mesa_image_row_stride() --- src/mesa/main/image.c | 42 +++++++++++++++++++----------------------- 1 file changed, 19 insertions(+), 23 deletions(-) (limited to 'src/mesa') diff --git a/src/mesa/main/image.c b/src/mesa/main/image.c index 58dd771484c..7c0b63b1738 100644 --- a/src/mesa/main/image.c +++ b/src/mesa/main/image.c @@ -651,44 +651,34 @@ _mesa_image_address3d( const struct gl_pixelstore_attrib *packing, /** - * Compute the stride between image rows. + * Compute the stride (in bytes) between image rows. * * \param packing the pixelstore attributes * \param width image width. * \param format pixel format. * \param type pixel data type. * - * \return the stride in bytes for the given parameters. + * \return the stride in bytes for the given parameters, or -1 if error */ GLint _mesa_image_row_stride( const struct gl_pixelstore_attrib *packing, GLint width, GLenum format, GLenum type ) { + GLint bytesPerRow, remainder; + ASSERT(packing); + if (type == GL_BITMAP) { - /* BITMAP data */ - GLint bytes, remainder; if (packing->RowLength == 0) { - bytes = (width + 7) / 8; + bytesPerRow = (width + 7) / 8; } else { - bytes = (packing->RowLength + 7) / 8; - } - if (packing->Invert) { - /* negate the bytes per row (negative row stride) */ - bytes = -bytes; + bytesPerRow = (packing->RowLength + 7) / 8; } - - remainder = bytes % packing->Alignment; - if (remainder > 0) - bytes += (packing->Alignment - remainder); - - return bytes; } else { /* Non-BITMAP data */ const GLint bytesPerPixel = _mesa_bytes_per_pixel(format, type); - GLint bytesPerRow, remainder; if (bytesPerPixel <= 0) return -1; /* error */ if (packing->RowLength == 0) { @@ -697,13 +687,19 @@ _mesa_image_row_stride( const struct gl_pixelstore_attrib *packing, else { bytesPerRow = bytesPerPixel * packing->RowLength; } - remainder = bytesPerRow % packing->Alignment; - if (remainder > 0) - bytesPerRow += (packing->Alignment - remainder); - if (packing->Invert) - bytesPerRow = -bytesPerRow; - return bytesPerRow; } + + remainder = bytesPerRow % packing->Alignment; + if (remainder > 0) { + bytesPerRow += (packing->Alignment - remainder); + } + + if (packing->Invert) { + /* negate the bytes per row (negative row stride) */ + bytesPerRow = -bytesPerRow; + } + + return bytesPerRow; } -- cgit v1.2.3 From 708d836e6b785764692c485e6cdf42f2b50fcf86 Mon Sep 17 00:00:00 2001 From: Michel Dänzer Date: Mon, 12 Mar 2007 19:08:28 +0100 Subject: i915tex: Don't crash when intel_fb->color_rb[i] is NULL. This can be the case on some systems when running glxinfo. --- src/mesa/drivers/dri/i915tex/intel_buffers.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/mesa') diff --git a/src/mesa/drivers/dri/i915tex/intel_buffers.c b/src/mesa/drivers/dri/i915tex/intel_buffers.c index 45fd2fa8de0..62ff54b0075 100644 --- a/src/mesa/drivers/dri/i915tex/intel_buffers.c +++ b/src/mesa/drivers/dri/i915tex/intel_buffers.c @@ -327,6 +327,9 @@ intelWindowMoved(struct intel_context *intel) } for (i = 0; i < intel_fb->pf_num_pages; i++) { + if (!intel_fb->color_rb[i]) + continue; + vbl.request.sequence = intel_fb->color_rb[i]->vbl_pending; drmWaitVBlank(intel->driFd, &vbl); } @@ -336,7 +339,8 @@ intelWindowMoved(struct intel_context *intel) intel_fb->vbl_waited = intel_fb->vbl_seq; for (i = 0; i < intel_fb->pf_num_pages; i++) { - intel_fb->color_rb[i]->vbl_pending = intel_fb->vbl_waited; + if (intel_fb->color_rb[i]) + intel_fb->color_rb[i]->vbl_pending = intel_fb->vbl_waited; } } } else { -- cgit v1.2.3 From 0c750ca98de5a08c0fe4c513a741c78b7bab80e3 Mon Sep 17 00:00:00 2001 From: Oliver McFadden Date: Tue, 13 Mar 2007 00:48:17 +0000 Subject: Guess another unknown register used for R300 pacification. --- src/mesa/drivers/dri/r300/r300_ioctl.c | 2 +- src/mesa/drivers/dri/r300/r300_reg.h | 4 ++++ src/mesa/drivers/dri/r300/r300_render.c | 4 ++-- 3 files changed, 7 insertions(+), 3 deletions(-) (limited to 'src/mesa') diff --git a/src/mesa/drivers/dri/r300/r300_ioctl.c b/src/mesa/drivers/dri/r300/r300_ioctl.c index 6fa34ee482a..41114a875dc 100644 --- a/src/mesa/drivers/dri/r300/r300_ioctl.c +++ b/src/mesa/drivers/dri/r300/r300_ioctl.c @@ -165,7 +165,7 @@ static void r300ClearBuffer(r300ContextPtr r300, int flags, int buffer) e32(0x0000000a); - reg_start(0x4f18,0); + reg_start(R300_RB3D_ZCACHE_CTLSTAT,0); e32(0x00000003); cp_wait(rmesa, R300_WAIT_3D | R300_WAIT_3D_CLEAN); } diff --git a/src/mesa/drivers/dri/r300/r300_reg.h b/src/mesa/drivers/dri/r300/r300_reg.h index 7bc832c871c..be357ab5c73 100644 --- a/src/mesa/drivers/dri/r300/r300_reg.h +++ b/src/mesa/drivers/dri/r300/r300_reg.h @@ -1395,6 +1395,10 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. /* gap */ +#define R300_RB3D_ZCACHE_CTLSTAT 0x4F18 /* GUESS */ + +/* gap */ + #define R300_RB3D_DEPTHOFFSET 0x4F20 #define R300_RB3D_DEPTHPITCH 0x4F24 # define R300_DEPTHPITCH_MASK 0x00001FF8 /* GUESS */ diff --git a/src/mesa/drivers/dri/r300/r300_render.c b/src/mesa/drivers/dri/r300/r300_render.c index 211c451f661..7a850b10010 100644 --- a/src/mesa/drivers/dri/r300/r300_render.c +++ b/src/mesa/drivers/dri/r300/r300_render.c @@ -346,7 +346,7 @@ GLboolean r300_run_vb_render(GLcontext *ctx, reg_start(R300_RB3D_DSTCACHE_CTLSTAT,0); e32(0x0000000a); - reg_start(0x4f18,0); + reg_start(R300_RB3D_ZCACHE_CTLSTAT,0); e32(0x00000003); r300EmitState(rmesa); @@ -362,7 +362,7 @@ GLboolean r300_run_vb_render(GLcontext *ctx, reg_start(R300_RB3D_DSTCACHE_CTLSTAT,0); e32(0x0000000a/*0x2*/); - reg_start(0x4f18,0); + reg_start(R300_RB3D_ZCACHE_CTLSTAT,0); e32(0x00000003/*0x1*/); #ifdef USER_BUFFERS -- cgit v1.2.3 From cd6660475646defb6311491028dfe50202709b59 Mon Sep 17 00:00:00 2001 From: Oliver McFadden Date: Tue, 13 Mar 2007 01:31:38 +0000 Subject: Corrected values written to R300_RB3D_DSTCACHE_CTLSTAT to either R300_RB3D_DSTCACHE_02 or R300_RB3D_DSTCACHE_0A, rather than hexadecimal values. --- src/mesa/drivers/dri/r300/r300_ioctl.c | 2 +- src/mesa/drivers/dri/r300/r300_render.c | 4 ++-- src/mesa/drivers/dri/r300/radeon_mm.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src/mesa') diff --git a/src/mesa/drivers/dri/r300/r300_ioctl.c b/src/mesa/drivers/dri/r300/r300_ioctl.c index 41114a875dc..bb16cd13d40 100644 --- a/src/mesa/drivers/dri/r300/r300_ioctl.c +++ b/src/mesa/drivers/dri/r300/r300_ioctl.c @@ -162,7 +162,7 @@ static void r300ClearBuffer(r300ContextPtr r300, int flags, int buffer) cmd2[8].u = r300PackFloat32(ctx->Color.ClearColor[3]); reg_start(R300_RB3D_DSTCACHE_CTLSTAT,0); - e32(0x0000000a); + e32(R300_RB3D_DSTCACHE_0A); reg_start(R300_RB3D_ZCACHE_CTLSTAT,0); diff --git a/src/mesa/drivers/dri/r300/r300_render.c b/src/mesa/drivers/dri/r300/r300_render.c index 7a850b10010..87d370e3038 100644 --- a/src/mesa/drivers/dri/r300/r300_render.c +++ b/src/mesa/drivers/dri/r300/r300_render.c @@ -344,7 +344,7 @@ GLboolean r300_run_vb_render(GLcontext *ctx, r300UpdateShaderStates(rmesa); reg_start(R300_RB3D_DSTCACHE_CTLSTAT,0); - e32(0x0000000a); + e32(R300_RB3D_DSTCACHE_0A); reg_start(R300_RB3D_ZCACHE_CTLSTAT,0); e32(0x00000003); @@ -360,7 +360,7 @@ GLboolean r300_run_vb_render(GLcontext *ctx, } reg_start(R300_RB3D_DSTCACHE_CTLSTAT,0); - e32(0x0000000a/*0x2*/); + e32(R300_RB3D_DSTCACHE_0A /*R300_RB3D_DSTCACHE_02*/); reg_start(R300_RB3D_ZCACHE_CTLSTAT,0); e32(0x00000003/*0x1*/); diff --git a/src/mesa/drivers/dri/r300/radeon_mm.c b/src/mesa/drivers/dri/r300/radeon_mm.c index 32ed1f43939..065f288e4ca 100644 --- a/src/mesa/drivers/dri/r300/radeon_mm.c +++ b/src/mesa/drivers/dri/r300/radeon_mm.c @@ -284,7 +284,7 @@ static void emit_lin_cp(r300ContextPtr rmesa, unsigned long dst, unsigned long s } reg_start(R300_RB3D_DSTCACHE_CTLSTAT,0); - e32(0x0000000a); + e32(R300_RB3D_DSTCACHE_0A); reg_start(0x342c,0); e32(0x00000005); -- cgit v1.2.3 From 53f83b435ce9a94092503712e3d4e16d4c942752 Mon Sep 17 00:00:00 2001 From: "Xiang, Haihao" Date: Tue, 13 Mar 2007 13:39:34 +0800 Subject: mesa: _mesa_unpack_image 1. take packed pixel data as a component 2. fix for GL_BITMAP when compiling glTexImage, etc into a display list: a. flip byte if lsbFirst is true since DefaultPacking->lsbFirst is false. b. handle SkipPixels --- src/mesa/main/image.c | 92 +++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 89 insertions(+), 3 deletions(-) (limited to 'src/mesa') diff --git a/src/mesa/main/image.c b/src/mesa/main/image.c index 7c0b63b1738..a60f4d3f4d8 100644 --- a/src/mesa/main/image.c +++ b/src/mesa/main/image.c @@ -59,6 +59,34 @@ #define CEILING( A, B ) ( (A) % (B) == 0 ? (A)/(B) : (A)/(B)+1 ) +/** + * \return GL_TRUE if type is packed pixel type, GL_FALSE otherwise. + */ +static GLboolean +_mesa_type_is_packed(GLenum type) + { + switch (type) { + case GL_UNSIGNED_BYTE_3_3_2: + case GL_UNSIGNED_BYTE_2_3_3_REV: + case GL_UNSIGNED_SHORT_5_6_5: + case GL_UNSIGNED_SHORT_5_6_5_REV: + case GL_UNSIGNED_SHORT_4_4_4_4: + case GL_UNSIGNED_SHORT_4_4_4_4_REV: + case GL_UNSIGNED_SHORT_5_5_5_1: + case GL_UNSIGNED_SHORT_1_5_5_5_REV: + case GL_UNSIGNED_INT_8_8_8_8: + case GL_UNSIGNED_INT_8_8_8_8_REV: + case GL_UNSIGNED_INT_10_10_10_2: + case GL_UNSIGNED_INT_2_10_10_10_REV: + case GL_UNSIGNED_SHORT_8_8_MESA: + case GL_UNSIGNED_SHORT_8_8_REV_MESA: + case GL_UNSIGNED_INT_24_8_EXT: + return GL_TRUE; + } + + return GL_FALSE; +} + /** * Flip the 8 bits in each byte of the given array. * @@ -4187,14 +4215,18 @@ _mesa_unpack_image( GLuint dimensions, if (type == GL_BITMAP) { bytesPerRow = (width + 7) >> 3; - flipBytes = !unpack->LsbFirst; + flipBytes = unpack->LsbFirst; swap2 = swap4 = GL_FALSE; compsPerRow = 0; } else { const GLint bytesPerPixel = _mesa_bytes_per_pixel(format, type); - const GLint components = _mesa_components_in_format(format); + GLint components = _mesa_components_in_format(format); GLint bytesPerComp; + + if (_mesa_type_is_packed(type)) + components = 1; + if (bytesPerPixel <= 0 || components <= 0) return NULL; /* bad format or type. generate error later */ bytesPerRow = bytesPerPixel * width; @@ -4219,7 +4251,61 @@ _mesa_unpack_image( GLuint dimensions, for (row = 0; row < height; row++) { const GLvoid *src = _mesa_image_address(dimensions, unpack, pixels, width, height, format, type, img, row, 0); - _mesa_memcpy(dst, src, bytesPerRow); + + if ((type == GL_BITMAP) && (unpack->SkipPixels & 0x7)) { + GLint i; + flipBytes = GL_FALSE; + if (unpack->LsbFirst) { + GLubyte srcMask = 1 << (unpack->SkipPixels & 0x7); + GLubyte dstMask = 128; + const GLubyte *s = src; + GLubyte *d = dst; + *d = 0; + for (i = 0; i < width; i++) { + if (*s & srcMask) { + *d |= dstMask; + } + if (srcMask == 128) { + srcMask = 1; + s++; + } else { + srcMask = srcMask << 1; + } + if (dstMask == 1) { + dstMask = 128; + d++; + *d = 0; + } else { + dstMask = dstMask >> 1; + } + } + } else { + GLubyte srcMask = 128 >> (unpack->SkipPixels & 0x7); + GLubyte dstMask = 128; + const GLubyte *s = src; + GLubyte *d = dst; + *d = 0; + for (i = 0; i < width; i++) { + if (*s & srcMask) { + *d |= dstMask; + } + if (srcMask == 1) { + srcMask = 128; + s++; + } else { + srcMask = srcMask >> 1; + } + if (dstMask == 1) { + dstMask = 128; + d++; + *d = 0; + } else { + dstMask = dstMask >> 1; + } + } + } + } else + _mesa_memcpy(dst, src, bytesPerRow); /* byte flipping/swapping */ if (flipBytes) { flip_bytes((GLubyte *) dst, bytesPerRow); -- cgit v1.2.3 From 19fbe9732c92ff67911c28bf19c174326af05c84 Mon Sep 17 00:00:00 2001 From: Oliver McFadden Date: Tue, 13 Mar 2007 06:08:36 +0000 Subject: Documented the value written for R300_TX_CNTL cache flush. --- src/mesa/drivers/dri/r300/r300_cmdbuf.c | 3 ++- src/mesa/drivers/dri/r300/r300_reg.h | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) (limited to 'src/mesa') diff --git a/src/mesa/drivers/dri/r300/r300_cmdbuf.c b/src/mesa/drivers/dri/r300/r300_cmdbuf.c index 89725447f1d..e4511e0c21c 100644 --- a/src/mesa/drivers/dri/r300/r300_cmdbuf.c +++ b/src/mesa/drivers/dri/r300/r300_cmdbuf.c @@ -174,11 +174,12 @@ static __inline__ void r300DoEmitState(r300ContextPtr r300, GLboolean dirty) dest ++; r300->cmdbuf.count_used ++; + /* Emit cache flush */ *dest = cmdpacket0(R300_TX_CNTL, 1); dest ++; r300->cmdbuf.count_used ++; - *dest = 0x0; + *dest = R300_TX_FLUSH; dest ++; r300->cmdbuf.count_used ++; diff --git a/src/mesa/drivers/dri/r300/r300_reg.h b/src/mesa/drivers/dri/r300/r300_reg.h index be357ab5c73..aa6d81a063a 100644 --- a/src/mesa/drivers/dri/r300/r300_reg.h +++ b/src/mesa/drivers/dri/r300/r300_reg.h @@ -497,6 +497,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. /* Zero to flush caches. */ #define R300_TX_CNTL 0x4100 +#define R300_TX_FLUSH 0x0 /* The upper enable bits are guessed, based on fglrx reported limits. */ #define R300_TX_ENABLE 0x4104 -- cgit v1.2.3 From eb4db4c4ec7efc366b00e1b1f1fe519ca1af79d6 Mon Sep 17 00:00:00 2001 From: Oliver McFadden Date: Tue, 13 Mar 2007 06:24:56 +0000 Subject: Add defines for the values written to R300_RB3D_ZCACHE_CTLSTAT. Note that just like the values written to R300_RB3D_DSTCACHE_CTLSTAT these values are really unknown; ideally more reverse engineering should be done to determine what these values mean and when they should be set. --- src/mesa/drivers/dri/r300/r300_ioctl.c | 2 +- src/mesa/drivers/dri/r300/r300_reg.h | 2 ++ src/mesa/drivers/dri/r300/r300_render.c | 4 ++-- 3 files changed, 5 insertions(+), 3 deletions(-) (limited to 'src/mesa') diff --git a/src/mesa/drivers/dri/r300/r300_ioctl.c b/src/mesa/drivers/dri/r300/r300_ioctl.c index bb16cd13d40..f0741f978d4 100644 --- a/src/mesa/drivers/dri/r300/r300_ioctl.c +++ b/src/mesa/drivers/dri/r300/r300_ioctl.c @@ -166,7 +166,7 @@ static void r300ClearBuffer(r300ContextPtr r300, int flags, int buffer) reg_start(R300_RB3D_ZCACHE_CTLSTAT,0); - e32(0x00000003); + e32(R300_RB3D_ZCACHE_CTLSTAT_03); cp_wait(rmesa, R300_WAIT_3D | R300_WAIT_3D_CLEAN); } diff --git a/src/mesa/drivers/dri/r300/r300_reg.h b/src/mesa/drivers/dri/r300/r300_reg.h index aa6d81a063a..f9accadf61c 100644 --- a/src/mesa/drivers/dri/r300/r300_reg.h +++ b/src/mesa/drivers/dri/r300/r300_reg.h @@ -1397,6 +1397,8 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. /* gap */ #define R300_RB3D_ZCACHE_CTLSTAT 0x4F18 /* GUESS */ +# define R300_RB3D_ZCACHE_CTLSTAT_01 0x1 +# define R300_RB3D_ZCACHE_CTLSTAT_03 0x3 /* gap */ diff --git a/src/mesa/drivers/dri/r300/r300_render.c b/src/mesa/drivers/dri/r300/r300_render.c index 87d370e3038..659ec3ff54c 100644 --- a/src/mesa/drivers/dri/r300/r300_render.c +++ b/src/mesa/drivers/dri/r300/r300_render.c @@ -347,7 +347,7 @@ GLboolean r300_run_vb_render(GLcontext *ctx, e32(R300_RB3D_DSTCACHE_0A); reg_start(R300_RB3D_ZCACHE_CTLSTAT,0); - e32(0x00000003); + e32(R300_RB3D_ZCACHE_CTLSTAT_03); r300EmitState(rmesa); @@ -363,7 +363,7 @@ GLboolean r300_run_vb_render(GLcontext *ctx, e32(R300_RB3D_DSTCACHE_0A /*R300_RB3D_DSTCACHE_02*/); reg_start(R300_RB3D_ZCACHE_CTLSTAT,0); - e32(0x00000003/*0x1*/); + e32(R300_RB3D_ZCACHE_CTLSTAT_03 /*R300_RB3D_ZCACHE_CTLSTAT_01*/); #ifdef USER_BUFFERS r300UseArrays(ctx); -- cgit v1.2.3