gallium: add bitmap/drawpixels texcoord bias support
authorBrian <brian.paul@tungstengraphics.com>
Tue, 5 Feb 2008 23:32:15 +0000 (16:32 -0700)
committerBrian <brian.paul@tungstengraphics.com>
Wed, 6 Feb 2008 16:35:38 +0000 (09:35 -0700)
The state tracker will call pipe->get_paramf(PIPE_CAP_BITMAP_TEXCOORD_BIAS)
to get a bias factor for adjusting the texcoords used in bitmap/drawpixels.
This allows us to compensate for small differences in rasterization from
one device to another.

src/mesa/pipe/p_defines.h
src/mesa/state_tracker/st_cb_drawpixels.c
src/mesa/state_tracker/st_context.h
src/mesa/state_tracker/st_extensions.c

index 85adf2d..0bf53ec 100644 (file)
@@ -265,6 +265,6 @@ enum pipe_texture_target {
 #define PIPE_CAP_MAX_POINT_WIDTH_AA      17
 #define PIPE_CAP_MAX_TEXTURE_ANISOTROPY  18
 #define PIPE_CAP_MAX_TEXTURE_LOD_BIAS    19
-
+#define PIPE_CAP_BITMAP_TEXCOORD_BIAS    20
 
 #endif
index 6b44cba..34d420f 100644 (file)
@@ -581,10 +581,13 @@ draw_quad_colored(GLcontext *ctx, GLfloat x0, GLfloat y0, GLfloat z,
                   GLfloat x1, GLfloat y1, const GLfloat *color,
                   GLboolean invertTex)
 {
+   GLfloat bias = ctx->st->bitmap_texcoord_bias;
    GLfloat verts[4][3][4]; /* four verts, three attribs, XYZW */
    GLuint i;
-   GLfloat sLeft = 0.0, sRight = 1.0;
-   GLfloat tTop = invertTex, tBot = 1.0 - tTop;
+   GLfloat xBias = bias / (x1-x0);
+   GLfloat yBias = bias / (y1-y0);
+   GLfloat sLeft = 0.0 + xBias, sRight = 1.0 + xBias;
+   GLfloat tTop = invertTex - yBias, tBot = 1.0 - tTop - yBias;
 
    /* upper-left */
    verts[0][0][0] = x0;    /* attr[0].x */
index 2b6f874..a756055 100644 (file)
@@ -143,6 +143,8 @@ struct st_context
 
    GLfloat polygon_offset_scale; /* ?? */
 
+   GLfloat bitmap_texcoord_bias;
+
    /** Mapping from VERT_RESULT_x to post-transformed vertex slot */
    const GLuint *vertex_result_to_slot;
 
index 0157bdd..97d28d7 100644 (file)
@@ -106,6 +106,9 @@ void st_init_limits(struct st_context *st)
 
    c->MaxTextureLodBias
       = pipe->get_paramf(pipe, PIPE_CAP_MAX_TEXTURE_LOD_BIAS);
+
+   st->bitmap_texcoord_bias
+      = pipe->get_paramf(pipe, PIPE_CAP_BITMAP_TEXCOORD_BIAS);
 }