summaryrefslogtreecommitdiff
path: root/src/mesa
diff options
context:
space:
mode:
authorNian Wu <nian.wu@intel.com>2007-03-13 17:00:18 +0800
committerNian Wu <nian.wu@intel.com>2007-03-13 17:00:18 +0800
commit4110fac38958003935f64e278d3a7b880523efe2 (patch)
tree1d123dcc2470c203d93a7918cb5a86fd25fd1e8a /src/mesa
parent5a5b55943dfdb7fac77f7556058791302ee8639b (diff)
parenteb4db4c4ec7efc366b00e1b1f1fe519ca1af79d6 (diff)
Merge git://proxy01.pd.intel.com:9419/git/mesa/mesa into crestline
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/drivers/dri/i915tex/intel_buffers.c6
-rw-r--r--src/mesa/drivers/dri/r200/r200_context.c6
-rw-r--r--src/mesa/drivers/dri/r200/r200_lock.c6
-rw-r--r--src/mesa/drivers/dri/r200/r200_state.c37
-rw-r--r--src/mesa/drivers/dri/r200/r200_state.h2
-rw-r--r--src/mesa/drivers/dri/r300/r300_cmdbuf.c3
-rw-r--r--src/mesa/drivers/dri/r300/r300_ioctl.c6
-rw-r--r--src/mesa/drivers/dri/r300/r300_reg.h7
-rw-r--r--src/mesa/drivers/dri/r300/r300_render.c12
-rw-r--r--src/mesa/drivers/dri/r300/radeon_mm.c2
-rw-r--r--src/mesa/drivers/dri/radeon/radeon_context.c10
-rw-r--r--src/mesa/drivers/dri/radeon/radeon_lock.c1
-rw-r--r--src/mesa/drivers/dri/radeon/radeon_state.c2
-rw-r--r--src/mesa/main/image.c129
14 files changed, 167 insertions, 62 deletions
diff --git a/src/mesa/drivers/dri/i915tex/intel_buffers.c b/src/mesa/drivers/dri/i915tex/intel_buffers.c
index 45fd2fa8de..62ff54b007 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 {
diff --git a/src/mesa/drivers/dri/r200/r200_context.c b/src/mesa/drivers/dri/r200/r200_context.c
index fc6eb93daa..3abcdf9e18 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);
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 bcc0c91639..9ffdb2b212 100644
--- a/src/mesa/drivers/dri/r200/r200_lock.c
+++ b/src/mesa/drivers/dri/r200/r200_lock.c
@@ -92,13 +92,9 @@ 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);
- 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 bdb487f2b9..16726d7d55 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,
@@ -1889,6 +1894,8 @@ void r200SetCliprects( r200ContextPtr rmesa, GLenum mode )
if (rmesa->state.scissor.enabled)
r200RecalcScissorRects( rmesa );
+
+ rmesa->lastStamp = drawable->lastStamp;
}
@@ -1908,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 98c6fbe40b..f34090b619 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 );
diff --git a/src/mesa/drivers/dri/r300/r300_cmdbuf.c b/src/mesa/drivers/dri/r300/r300_cmdbuf.c
index 89725447f1..e4511e0c21 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_ioctl.c b/src/mesa/drivers/dri/r300/r300_ioctl.c
index 6fa34ee482..f0741f978d 100644
--- a/src/mesa/drivers/dri/r300/r300_ioctl.c
+++ b/src/mesa/drivers/dri/r300/r300_ioctl.c
@@ -162,11 +162,11 @@ 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(0x4f18,0);
- e32(0x00000003);
+ reg_start(R300_RB3D_ZCACHE_CTLSTAT,0);
+ 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 7bc832c871..f9accadf61 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
@@ -1395,6 +1396,12 @@ 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 */
+
#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 211c451f66..659ec3ff54 100644
--- a/src/mesa/drivers/dri/r300/r300_render.c
+++ b/src/mesa/drivers/dri/r300/r300_render.c
@@ -344,10 +344,10 @@ 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(0x4f18,0);
- e32(0x00000003);
+ reg_start(R300_RB3D_ZCACHE_CTLSTAT,0);
+ e32(R300_RB3D_ZCACHE_CTLSTAT_03);
r300EmitState(rmesa);
@@ -360,10 +360,10 @@ 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(0x4f18,0);
- e32(0x00000003/*0x1*/);
+ reg_start(R300_RB3D_ZCACHE_CTLSTAT,0);
+ e32(R300_RB3D_ZCACHE_CTLSTAT_03 /*R300_RB3D_ZCACHE_CTLSTAT_01*/);
#ifdef USER_BUFFERS
r300UseArrays(ctx);
diff --git a/src/mesa/drivers/dri/r300/radeon_mm.c b/src/mesa/drivers/dri/r300/radeon_mm.c
index 32ed1f4393..065f288e4c 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);
diff --git a/src/mesa/drivers/dri/radeon/radeon_context.c b/src/mesa/drivers/dri/radeon/radeon_context.c
index 6bc2c4aa5c..0d25951b64 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 e6ab6af456..cdf8a19fb1 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 e19202fa44..4de05c7697 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;
}
diff --git a/src/mesa/main/image.c b/src/mesa/main/image.c
index eb91ebb611..a60f4d3f4d 100644
--- a/src/mesa/main/image.c
+++ b/src/mesa/main/image.c
@@ -60,6 +60,34 @@
/**
+ * \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.
*
* \param p array.
@@ -651,39 +679,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;
if (packing->RowLength == 0) {
- bytes = (width + 7) / 8;
+ bytesPerRow = (width + 7) / 8;
}
else {
- bytes = (packing->RowLength + 7) / 8;
+ bytesPerRow = (packing->RowLength + 7) / 8;
}
- if (packing->Invert) {
- /* negate the bytes per row (negative row stride) */
- bytes = -bytes;
- }
- 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) {
@@ -692,13 +715,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;
}
@@ -4186,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;
@@ -4218,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);