summaryrefslogtreecommitdiffstats
path: root/src/mesa
diff options
context:
space:
mode:
authorBrian <[email protected]>2008-02-05 16:32:15 -0700
committerBrian <[email protected]>2008-02-06 09:35:38 -0700
commit4650b35846e8e87fb0d74573a5f66452bb449b4b (patch)
tree2fdc925f9ffd00e7196993a1177504aedd6189e1 /src/mesa
parentaf6b12cc76b40c86f3b144a7f5cd3ef1278863d0 (diff)
gallium: add bitmap/drawpixels texcoord bias support
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.
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/pipe/p_defines.h2
-rw-r--r--src/mesa/state_tracker/st_cb_drawpixels.c7
-rw-r--r--src/mesa/state_tracker/st_context.h2
-rw-r--r--src/mesa/state_tracker/st_extensions.c3
4 files changed, 11 insertions, 3 deletions
diff --git a/src/mesa/pipe/p_defines.h b/src/mesa/pipe/p_defines.h
index 85adf2d61df..0bf53ecb79d 100644
--- a/src/mesa/pipe/p_defines.h
+++ b/src/mesa/pipe/p_defines.h
@@ -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
diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c
index 6b44cba2e40..34d420fcffa 100644
--- a/src/mesa/state_tracker/st_cb_drawpixels.c
+++ b/src/mesa/state_tracker/st_cb_drawpixels.c
@@ -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 */
diff --git a/src/mesa/state_tracker/st_context.h b/src/mesa/state_tracker/st_context.h
index 2b6f8743f38..a756055898d 100644
--- a/src/mesa/state_tracker/st_context.h
+++ b/src/mesa/state_tracker/st_context.h
@@ -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;
diff --git a/src/mesa/state_tracker/st_extensions.c b/src/mesa/state_tracker/st_extensions.c
index 0157bdd6b32..97d28d77c4b 100644
--- a/src/mesa/state_tracker/st_extensions.c
+++ b/src/mesa/state_tracker/st_extensions.c
@@ -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);
}