summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBrian Paul <brianp@vmware.com>2009-01-12 15:43:54 -0700
committerBrian Paul <brianp@vmware.com>2009-01-12 15:43:54 -0700
commit3a5463d158eff483a992c9792d771fb80db9aed0 (patch)
tree00cbb602a3a4fdb920a945139cc713e815267f3a /src
parentde35989cdec9807c60b2b4389e5988037ce23d95 (diff)
i965: fix broken glBitmap + depth test
When we use the do_blit_bitmap() function, it seems the fragment Z is always 1.0. If depth testing is on, that means that bitmap fragments are often occluded by other rendering. So, the bitmap doesn't appear even if rasterpos.Z==0. The fix is to use the intel_texture_bitmap() path when depth testing is on. Also, fix the incorrect Z coordinate. It needs to be an NDC value in [-1,1].
Diffstat (limited to 'src')
-rw-r--r--src/mesa/drivers/dri/intel/intel_pixel_bitmap.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/src/mesa/drivers/dri/intel/intel_pixel_bitmap.c b/src/mesa/drivers/dri/intel/intel_pixel_bitmap.c
index 1d7f15f10a..3a01f63dc7 100644
--- a/src/mesa/drivers/dri/intel/intel_pixel_bitmap.c
+++ b/src/mesa/drivers/dri/intel/intel_pixel_bitmap.c
@@ -204,6 +204,14 @@ do_blit_bitmap( GLcontext *ctx,
/* Update draw buffer bounds */
_mesa_update_state(ctx);
+ if (ctx->Depth.Test) {
+ /* The blit path produces incorrect results when depth testing is on.
+ * It seems the blit Z coord is always 1.0 (the far plane) so fragments
+ * will likely be obscured by other, closer geometry.
+ */
+ return GL_FALSE;
+ }
+
if (!dst)
return GL_FALSE;
@@ -357,6 +365,7 @@ intel_texture_bitmap(GLcontext * ctx,
GLubyte *unpacked_bitmap;
GLubyte *a8_bitmap;
int x, y;
+ GLfloat dst_z;
/* We need a fragment program for the KIL effect */
if (!ctx->Extensions.ARB_fragment_program ||
@@ -456,21 +465,24 @@ intel_texture_bitmap(GLcontext * ctx,
intel_meta_set_passthrough_vertex_program(intel);
intel_meta_set_passthrough_transform(intel);
+ /* convert rasterpos Z from [0,1] to NDC coord in [-1,1] */
+ dst_z = -1.0 + 2.0 * ctx->Current.RasterPos[2];
+
vertices[0][0] = dst_x;
vertices[0][1] = dst_y;
- vertices[0][2] = ctx->Current.RasterPos[2];
+ vertices[0][2] = dst_z;
vertices[0][3] = 1.0;
vertices[1][0] = dst_x + width;
vertices[1][1] = dst_y;
- vertices[1][2] = ctx->Current.RasterPos[2];
+ vertices[1][2] = dst_z;
vertices[1][3] = 1.0;
vertices[2][0] = dst_x + width;
vertices[2][1] = dst_y + height;
- vertices[2][2] = ctx->Current.RasterPos[2];
+ vertices[2][2] = dst_z;
vertices[2][3] = 1.0;
vertices[3][0] = dst_x;
vertices[3][1] = dst_y + height;
- vertices[3][2] = ctx->Current.RasterPos[2];
+ vertices[3][2] = dst_z;
vertices[3][3] = 1.0;
texcoords[0][0] = 0.0;